Skip to content

Commit ecb6dd9

Browse files
authored
Added hasattr and getattr tests
1 parent aa79dba commit ecb6dd9

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
using Tensorflow;
6+
7+
namespace TensorFlowNET.UnitTest
8+
{
9+
[TestClass]
10+
public class PythonBaseTests : PythonTest
11+
{
12+
[TestMethod]
13+
public void hasattr_getattr()
14+
{
15+
var s1 = "Tensorflow v0.1";
16+
var f = "Tensorflow";
17+
var r = "Tensorflow.NET";
18+
var res = s1.Replace(f, r);
19+
20+
// Test 1
21+
Assert.IsTrue(hasattr(s1, "Replace"));
22+
23+
// Test 2
24+
var o = getattr( s1, "Replace", typeof(string), typeof(string));
25+
Assert.AreEqual(res, o(f, r));
26+
27+
// Test 3
28+
var l = getattr(s1, "Length");
29+
Assert.AreEqual(s1.Length, l());
30+
31+
}
32+
}
33+
}
34+

0 commit comments

Comments
 (0)