1- using FluentAssertions ;
2- using Microsoft . VisualStudio . TestTools . UnitTesting ;
1+ using Microsoft . VisualStudio . TestTools . UnitTesting ;
32using Tensorflow . NumPy ;
43using System ;
54using System . IO ;
65using System . Linq ;
76using System . Runtime . InteropServices ;
87using Tensorflow ;
9- using Tensorflow . UnitTest ;
108using static Tensorflow . Binding ;
119
1210namespace TensorFlowNET . UnitTest
@@ -24,15 +22,15 @@ public void SessionCreation()
2422 //the core method
2523 void Core ( int tid )
2624 {
27- tf . peak_default_graph ( ) . Should ( ) . BeNull ( ) ;
25+ Assert . IsNull ( tf . peak_default_graph ( ) ) ;
2826
2927 using ( var sess = tf . Session ( ) )
3028 {
3129 var default_graph = tf . peak_default_graph ( ) ;
32- var sess_graph = sess . GetPrivate < Graph > ( "_graph" ) ;
33- sess_graph . Should ( ) . NotBeNull ( ) ;
34- default_graph . Should ( ) . NotBeNull ( )
35- . And . BeEquivalentTo ( sess_graph ) ;
30+ var sess_graph = sess . graph ;
31+ Assert . IsNotNull ( default_graph ) ;
32+ Assert . IsNotNull ( sess_graph ) ;
33+ Assert . AreEqual ( default_graph , sess_graph ) ;
3634 }
3735 }
3836 }
@@ -47,15 +45,15 @@ public void SessionCreation_x2()
4745 //the core method
4846 void Core ( int tid )
4947 {
50- tf . peak_default_graph ( ) . Should ( ) . BeNull ( ) ;
48+ Assert . IsNull ( tf . peak_default_graph ( ) ) ;
5149 //tf.Session created an other graph
5250 using ( var sess = tf . Session ( ) )
5351 {
5452 var default_graph = tf . peak_default_graph ( ) ;
55- var sess_graph = sess . GetPrivate < Graph > ( "_graph" ) ;
56- sess_graph . Should ( ) . NotBeNull ( ) ;
57- default_graph . Should ( ) . NotBeNull ( )
58- . And . BeEquivalentTo ( sess_graph ) ;
53+ var sess_graph = sess . graph ;
54+ Assert . IsNotNull ( default_graph ) ;
55+ Assert . IsNotNull ( sess_graph ) ;
56+ Assert . AreEqual ( default_graph , sess_graph ) ;
5957 }
6058 }
6159 }
@@ -70,19 +68,18 @@ public void GraphCreation()
7068 //the core method
7169 void Core ( int tid )
7270 {
73- tf . peak_default_graph ( ) . Should ( ) . BeNull ( ) ;
71+ Assert . IsNull ( tf . peak_default_graph ( ) ) ;
7472 var beforehand = tf . get_default_graph ( ) ; //this should create default automatically.
75- beforehand . graph_key . Should ( ) . NotContain ( "-0/" , "Already created a graph in an other thread." ) ;
7673 beforehand . as_default ( ) ;
77- tf . peak_default_graph ( ) . Should ( ) . NotBeNull ( ) ;
74+ Assert . IsNotNull ( tf . peak_default_graph ( ) ) ;
7875
7976 using ( var sess = tf . Session ( ) )
8077 {
8178 var default_graph = tf . peak_default_graph ( ) ;
82- var sess_graph = sess . GetPrivate < Graph > ( "_graph" ) ;
83- sess_graph . Should ( ) . NotBeNull ( ) ;
84- default_graph . Should ( ) . NotBeNull ( )
85- . And . BeEquivalentTo ( sess_graph ) ;
79+ var sess_graph = sess . graph ;
80+ Assert . IsNotNull ( default_graph ) ;
81+ Assert . IsNotNull ( sess_graph ) ;
82+ Assert . AreEqual ( default_graph , sess_graph ) ;
8683
8784 Console . WriteLine ( $ "{ tid } -{ default_graph . graph_key } ") ;
8885
@@ -188,7 +185,7 @@ public void SessionRun()
188185 //the core method
189186 void Core ( int tid )
190187 {
191- tf . peak_default_graph ( ) . Should ( ) . BeNull ( ) ;
188+ Assert . IsNull ( tf . peak_default_graph ( ) ) ;
192189 //graph is created automatically to perform create these operations
193190 var a1 = tf . constant ( new [ ] { 2f } , shape : new [ ] { 1 } ) ;
194191 var a2 = tf . constant ( new [ ] { 3f } , shape : new [ ] { 1 } ) ;
@@ -197,7 +194,8 @@ void Core(int tid)
197194 {
198195 using ( var sess = tf . Session ( ) )
199196 {
200- sess . run ( math ) . GetAtIndex < float > ( 0 ) . Should ( ) . Be ( 5 ) ;
197+ var result = sess . run ( math ) ;
198+ Assert . AreEqual ( result . GetAtIndex < float > ( 0 ) , 5f ) ;
201199 }
202200 }
203201 }
@@ -213,14 +211,14 @@ void Core(int tid)
213211 {
214212 using ( var sess = tf . Session ( ) )
215213 {
216- tf . peak_default_graph ( ) . Should ( ) . NotBeNull ( ) ;
214+ Assert . IsNotNull ( tf . peak_default_graph ( ) ) ;
217215 //graph is created automatically to perform create these operations
218216 var a1 = tf . constant ( new [ ] { 2f } , shape : new [ ] { 1 } ) ;
219217 var a2 = tf . constant ( new [ ] { 3f } , shape : new [ ] { 1 } ) ;
220218 var math = a1 + a2 ;
221219
222220 var result = sess . run ( math ) ;
223- result . GetAtIndex < float > ( 0 ) . Should ( ) . Be ( 5 ) ;
221+ Assert . AreEqual ( result . GetAtIndex < float > ( 0 ) , 5f ) ;
224222 }
225223 }
226224 }
@@ -235,7 +233,7 @@ void Core(int tid)
235233 {
236234 using ( var sess = tf . Session ( ) )
237235 {
238- tf . peak_default_graph ( ) . Should ( ) . NotBeNull ( ) ;
236+ Assert . IsNotNull ( tf . peak_default_graph ( ) ) ;
239237 //graph is created automatically to perform create these operations
240238 var a1 = tf . constant ( new [ ] { 2f } , shape : new [ ] { 1 } ) ;
241239 var a2 = tf . constant ( new [ ] { 3f } , shape : new [ ] { 1 } ) ;
@@ -252,7 +250,7 @@ public void SessionRun_Initialization_OutsideSession()
252250 //the core method
253251 void Core ( int tid )
254252 {
255- tf . peak_default_graph ( ) . Should ( ) . BeNull ( ) ;
253+ Assert . IsNull ( tf . peak_default_graph ( ) ) ;
256254 //graph is created automatically to perform create these operations
257255 var a1 = tf . constant ( new [ ] { 2f } , shape : new [ ] { 1 } ) ;
258256 var a2 = tf . constant ( new [ ] { 3f } , shape : new [ ] { 1 } ) ;
@@ -268,7 +266,7 @@ public void TF_GraphOperationByName()
268266 //the core method
269267 void Core ( int tid )
270268 {
271- tf . peak_default_graph ( ) . Should ( ) . BeNull ( ) ;
269+ Assert . IsNull ( tf . peak_default_graph ( ) ) ;
272270 //graph is created automatically to perform create these operations
273271 var a1 = tf . constant ( new [ ] { 2f } , shape : new [ ] { 1 } ) ;
274272 var a2 = tf . constant ( new [ ] { 3f } , shape : new [ ] { 1 } , name : "ConstantK" ) ;
0 commit comments