public void Serialization() { string path = Path.Combine(Path.GetTempPath(), "CadruTest"); Directory.CreateDirectory(path); ExtendedDirectoryInfo edi = new ExtendedDirectoryInfo(path); Assert.IsNotNull(edi); byte[] data = null; using (MemoryStream stream = new MemoryStream()) { BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(stream, edi); data = stream.ToArray(); } Assert.IsNotNull(data); ConditionAssert.Greater(data.Length, 0); using (MemoryStream stream = new MemoryStream(data)) { BinaryFormatter bf = new BinaryFormatter(); ExtendedDirectoryInfo edi2 = bf.Deserialize(stream) as ExtendedDirectoryInfo; Assert.IsNotNull(edi2); Assert.AreEqual(edi.FullName, edi2.FullName); } }
public void Serialization() { string tempFile = Path.GetTempFileName(); ExtendedFileInfo efi = new ExtendedFileInfo(tempFile); Assert.IsNotNull(efi); byte[] data = null; using (MemoryStream stream = new MemoryStream()) { BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(stream, efi); data = stream.ToArray(); } Assert.IsNotNull(data); ConditionAssert.Greater(data.Length, 0); using (MemoryStream stream = new MemoryStream(data)) { BinaryFormatter bf = new BinaryFormatter(); ExtendedFileInfo efi2 = bf.Deserialize(stream) as ExtendedFileInfo; Assert.IsNotNull(efi2); Assert.AreEqual(efi.FullName, efi2.FullName); } }
public void Greater() { ConditionAssert.Greater(this.i1, this.i2); ConditionAssert.Greater(this.u1, this.u2); ConditionAssert.Greater(this.d1, this.d2, "double"); ConditionAssert.Greater(this.de1, this.de2, "{0}", "decimal"); ConditionAssert.Greater(this.f1, this.f2, "float"); }
public void Greater() { ConditionAssert.Greater(i1, i2); ConditionAssert.Greater(u1, u2); ConditionAssert.Greater(d1, d2, "double"); ConditionAssert.Greater(de1, de2, "{0}", "decimal"); ConditionAssert.Greater(f1, f2, "float"); }
public void Operators() { ConditionAssert.IsTrue(UnixTimestamp.MaxValue > UnixTimestamp.MinValue); ConditionAssert.IsFalse(UnixTimestamp.MinValue >= UnixTimestamp.MaxValue); ConditionAssert.IsFalse(UnixTimestamp.MaxValue <= UnixTimestamp.MinValue); ConditionAssert.IsTrue(UnixTimestamp.MinValue < UnixTimestamp.MaxValue); ConditionAssert.IsTrue(((UnixTimestamp)1395176400L) == ((UnixTimestamp)1395176400L)); ConditionAssert.IsTrue(UnixTimestamp.MinValue != UnixTimestamp.MaxValue); }
public void GetServerInfo() { ServerInfo server = ExtendedNetworkInformation.GetServerInfo(); Assert.IsNotNull(server); Assert.IsNotNull(server.Name); Assert.IsTrue(server.Name.Length > 0); Assert.IsNotNull(server.Version); ConditionAssert.GreaterOrEqual(server.MajorVersion, 0); ConditionAssert.GreaterOrEqual(server.MinorVersion, 0); Assert.AreEqual(server.MajorVersion, server.Version.Major); Assert.AreEqual(server.MinorVersion, server.Version.Minor); Assert.IsNotNull(server.Comment); Assert.IsTrue(Enum.IsDefined(typeof(PlatformId), server.PlatformId)); Assert.IsTrue(server.ServerType.HasFlag(ServerTypes.WindowsNT)); ServerInfo server2 = ExtendedNetworkInformation.GetServerInfo("localhost"); Assert.IsNotNull(server2); ServerInfo server3 = ExtendedNetworkInformation.GetServerInfo(@"\\localhost"); Assert.IsNotNull(server3); Assert.AreNotEqual(server, server2); Assert.AreEqual(server2, server3); try { ExtendedNetworkInformation.GetServerInfo(null); } catch (ArgumentNullException) { Assert.IsTrue(true); } catch (Exception e) { Assert.Fail(e.Message); } try { ExtendedNetworkInformation.GetServerInfo("\\goofy"); } catch (Win32Exception e) { Assert.IsTrue(true, e.Message); } catch (Exception e) { Assert.Fail(e.Message); } }
public void Comparison() { UnixTimestamp timestamp = rawTimestamp; UnixTimestamp timestamp2 = rawTimestamp; var timestamp3 = new UnixTimestamp(rawTimestamp).AddMonths(1); var timestamp4 = new UnixTimestamp(rawTimestamp).AddMonths(-1); Assert.AreEqual(1, timestamp.CompareTo(null)); ExceptionAssert.Throws <ArgumentException>(() => timestamp.CompareTo("test")); Assert.AreEqual(0, timestamp.CompareTo((object)timestamp2)); Assert.AreEqual(0, timestamp.CompareTo(timestamp2)); ConditionAssert.Greater(0, timestamp.CompareTo(timestamp3)); ConditionAssert.Less(0, timestamp.CompareTo(timestamp4)); }
public void FailureMessage() { string msg = null; try { ConditionAssert.Greater(7, 99); } catch (AssertFailedException ex) { msg = ex.Message; } StringAssert.Contains("Assert.Fail failed. 99 is less than or equal to 7.", msg); }
public void FailureMessage() { string msg = null; try { ConditionAssert.Less(9, 4); } catch (AssertFailedException ex) { msg = ex.Message; } StringAssert.Contains("Assert.Fail failed. 4 is greater than or equal to 9.", msg); }
public void Less() { ConditionAssert.Less(i1, i2); ConditionAssert.Less(i1, i2, "int"); ConditionAssert.Less(i1, i2, "{0}", "int"); ConditionAssert.Less(u1, u2, "uint"); ConditionAssert.Less(u1, u2, "{0}", "uint"); ConditionAssert.Less(d1, d2); ConditionAssert.Less(d1, d2, "double"); ConditionAssert.Less(d1, d2, "{0}", "double"); ConditionAssert.Less(de1, de2); ConditionAssert.Less(de1, de2, "decimal"); ConditionAssert.Less(de1, de2, "{0}", "decimal"); ConditionAssert.Less(f1, f2); ConditionAssert.Less(f1, f2, "float"); ConditionAssert.Less(f1, f2, "{0}", "float"); }
public void Less() { ConditionAssert.Less(this.i1, this.i2); ConditionAssert.Less(this.i1, this.i2, "int"); ConditionAssert.Less(this.i1, this.i2, "{0}", "int"); ConditionAssert.Less(this.u1, this.u2, "uint"); ConditionAssert.Less(this.u1, this.u2, "{0}", "uint"); ConditionAssert.Less(this.d1, this.d2); ConditionAssert.Less(this.d1, this.d2, "double"); ConditionAssert.Less(this.d1, this.d2, "{0}", "double"); ConditionAssert.Less(this.de1, this.de2); ConditionAssert.Less(this.de1, this.de2, "decimal"); ConditionAssert.Less(this.de1, this.de2, "{0}", "decimal"); ConditionAssert.Less(this.f1, this.f2); ConditionAssert.Less(this.f1, this.f2, "float"); ConditionAssert.Less(this.f1, this.f2, "{0}", "float"); }
public void IsNaNFails() { ConditionAssert.IsNaN(10.0); }
public void IsNaN() { ConditionAssert.IsNaN(double.NaN); }
public void NotGreaterIComparable() { ConditionAssert.Greater(e2, e1); }
public void NotLess() { ConditionAssert.Less(this.i2, this.i1); }
public void NotGreaterWhenEqual() { ConditionAssert.Greater(i1, i1); }
public void NotGreater() { ConditionAssert.Greater(i2, i1); }
public void NotGreater() { ConditionAssert.Greater(this.i2, this.i1); }
public void NotLessIComparable() { ConditionAssert.Less(System.Net.DecompressionMethods.Deflate, System.Net.DecompressionMethods.GZip); }
public void NotGreaterIComparable() { ConditionAssert.Greater(System.Net.DecompressionMethods.GZip, System.Net.DecompressionMethods.Deflate); }
public void IsNaN() { ConditionAssert.IsNaN(System.Double.NaN); }
public void NotLessWhenEqual() { ConditionAssert.Less(i1, i1); }
public void NotLess() { ConditionAssert.Less(i2, i1); }
public void NotLessWhenEqual() { ConditionAssert.Less(this.i1, this.i1); }
public void TryParse() { ConditionAssert.IsTrue(TryParse("true")); ConditionAssert.IsTrue(TryParse("True")); ConditionAssert.IsTrue(TryParse("TRUE")); ConditionAssert.IsTrue(TryParse("T")); ConditionAssert.IsTrue(TryParse("t")); ConditionAssert.IsTrue(TryParse("Y")); ConditionAssert.IsTrue(TryParse("y")); ConditionAssert.IsTrue(TryParse("YES")); ConditionAssert.IsTrue(TryParse("Yes")); ConditionAssert.IsTrue(TryParse("yes")); ConditionAssert.IsFalse(TryParse("false")); ConditionAssert.IsFalse(TryParse("False")); ConditionAssert.IsFalse(TryParse("FALSE")); ConditionAssert.IsFalse(TryParse("F")); ConditionAssert.IsFalse(TryParse("f")); ConditionAssert.IsFalse(TryParse("N")); ConditionAssert.IsFalse(TryParse("n")); ConditionAssert.IsFalse(TryParse("NO")); ConditionAssert.IsFalse(TryParse("No")); ConditionAssert.IsFalse(TryParse("no")); ConditionAssert.IsFalse(TryParse("NA")); ConditionAssert.IsFalse(TryParse("Na")); ConditionAssert.IsFalse(TryParse("na")); ConditionAssert.IsFalse(TryParse("N/A")); ConditionAssert.IsFalse(TryParse("N/a")); ConditionAssert.IsFalse(TryParse("n/a")); ConditionAssert.IsTrue(TryParse("true ")); ConditionAssert.IsTrue(TryParse(" True")); ConditionAssert.IsTrue(TryParse("TRUE ")); ConditionAssert.IsTrue(TryParse("T ")); ConditionAssert.IsTrue(TryParse(" t")); ConditionAssert.IsTrue(TryParse("Y ")); ConditionAssert.IsTrue(TryParse(" y")); ConditionAssert.IsTrue(TryParse("YES ")); ConditionAssert.IsTrue(TryParse(" Yes")); ConditionAssert.IsTrue(TryParse(" yes ")); ConditionAssert.IsFalse(TryParse(" false")); ConditionAssert.IsFalse(TryParse("False ")); ConditionAssert.IsFalse(TryParse("FALSE ")); ConditionAssert.IsFalse(TryParse(" F")); ConditionAssert.IsFalse(TryParse("f ")); ConditionAssert.IsFalse(TryParse("N ")); ConditionAssert.IsFalse(TryParse(" n")); ConditionAssert.IsFalse(TryParse("NO ")); ConditionAssert.IsFalse(TryParse(" No")); ConditionAssert.IsFalse(TryParse("no ")); ConditionAssert.IsFalse(TryParse("NA ")); ConditionAssert.IsFalse(TryParse(" Na")); ConditionAssert.IsFalse(TryParse("na ")); ConditionAssert.IsFalse(TryParse(" N/A ")); ConditionAssert.IsFalse(TryParse(" N/a")); ConditionAssert.IsFalse(TryParse("n/a ")); ConditionAssert.IsTrue(TryParse(1)); ConditionAssert.IsFalse(TryParse(0)); Assert.IsNull(TryParse("foo")); Assert.IsNull(TryParse(" foo")); Assert.IsNull(TryParse(3)); Assert.IsNull(TryParse("")); Assert.IsNull(TryParse("\0")); Assert.IsNull(TryParse("\u0089")); Assert.IsNull(TryParse("\t")); Assert.IsNull(TryParse("\u0100")); Assert.IsNull(TryParse("\u0089\t")); Assert.IsNull(TryParse("\u0089\0")); Assert.IsNull(TryParse("\t\0")); Assert.IsNull(TryParse("\t\0\0")); Assert.IsNull(TryParse("\u0100\0\0")); Assert.IsNull(TryParse("\u0100\t\t")); Assert.IsNull(TryParse("\t\t")); }
public void NotLessIComparable() { ConditionAssert.Less(e2, e1); }