public void ID_Intern_FindOrCreate_derived_class() { Interner <int, A> interner = new Interner <int, A>(); var obj1 = new A(); var obj2 = new B(); var obj3 = new B(); var r1 = interner.FindOrCreate(1, () => obj1); Assert.AreEqual(obj1, r1, "Objects should be equal"); Assert.AreSame(obj1, r1, "Objects should be same / intern'ed"); var r2 = interner.FindOrCreate(2, () => obj2); Assert.AreEqual(obj2, r2, "Objects should be equal"); Assert.AreSame(obj2, r2, "Objects should be same / intern'ed"); // FindOrCreate should not replace instances of same class var r3 = interner.FindOrCreate(2, () => obj3); Assert.AreSame(obj2, r3, "FindOrCreate should return previous object"); Assert.AreNotSame(obj3, r3, "FindOrCreate should not replace previous object of same class"); // FindOrCreate should not replace cached instances with instances of most derived class var r4 = interner.FindOrCreate(1, () => obj2); Assert.AreSame(obj1, r4, "FindOrCreate return previously cached object"); Assert.AreNotSame(obj2, r4, "FindOrCreate should not replace previously cached object"); // FindOrCreate should not replace cached instances with instances of less derived class var r5 = interner.FindOrCreate(2, () => obj1); Assert.AreNotSame(obj1, r5, "FindOrCreate should not replace previously cached object"); Assert.AreSame(obj2, r5, "FindOrCreate return previously cached object"); }
public void ID_Intern_derived_class() { Interner <int, A> interner = new Interner <int, A>(); var obj1 = new A(); var obj2 = new B(); var obj3 = new B(); var r1 = interner.InternAndUpdateWithMoreDerived(1, obj1); Assert.AreEqual(obj1, r1, "Objects should be equal"); Assert.AreSame(obj1, r1, "Objects should be same / intern'ed"); var r2 = interner.InternAndUpdateWithMoreDerived(2, obj2); Assert.AreEqual(obj2, r2, "Objects should be equal"); Assert.AreSame(obj2, r2, "Objects should be same / intern'ed"); // Interning should not replace instances of same class var r3 = interner.InternAndUpdateWithMoreDerived(2, obj3); Assert.AreSame(obj2, r3, "Interning should return previous object"); Assert.AreNotSame(obj3, r3, "Interning should not replace previous object of same class"); // Interning should return instances of most derived class var r4 = interner.InternAndUpdateWithMoreDerived(1, obj2); Assert.AreSame(obj2, r4, "Interning should return most derived object"); Assert.AreNotSame(obj1, r4, "Interning should replace cached instances of less derived object"); // Interning should not return instances of less derived class var r5 = interner.InternAndUpdateWithMoreDerived(2, obj1); Assert.AreNotSame(obj1, r5, "Interning should not return less derived object"); Assert.AreSame(obj2, r5, "Interning should return previously cached instances of more derived object"); }
public void ProtobuffSerializationTest_5_DeepCopy() { var input = CreateAddressBook(); var output = SerializationManager.DeepCopy(input); Assert.AreNotSame(input, output, "The serializer returned an instance of the same object"); Assert.AreEqual(input, output, "The serialization didn't preserve the proper value"); }
public void ProtobuffSerializationTest_4_ProtoSerialization() { var input = CreateCounter(); var output = SerializationManager.RoundTripSerializationForTesting(input); Assert.AreNotSame(input, output, "The serializer returned an instance of the same object"); Assert.AreEqual(input, output, "The serialization didn't preserve the proper value"); }
public void ProtobuffSerializationTest_2_RegularOrleansSerializationStillWorks() { var input = new OrleansType(); var output = SerializationManager.RoundTripSerializationForTesting(input); Assert.AreNotSame(input, output, "The serializer returned an instance of the same object"); Assert.AreEqual(input, output, "The serialization didn't preserve the proper value"); }
public void Interning_SiloAddress2() { SiloAddress a1 = SiloAddress.New(new IPEndPoint(IPAddress.Loopback, 1111), 12345); SiloAddress a2 = SiloAddress.New(new IPEndPoint(IPAddress.Loopback, 2222), 12345); Assert.AreNotEqual(a1, a2, "Should not be equal SiloAddress's"); Assert.AreNotSame(a1, a2, "Should not be same / intern'ed SiloAddress object"); }
public void SimpleGenericBondSchemaCopyTest() { var schema = new SimpleGenericSchema <int> { SomeValue = int.MaxValue }; var output = SerializationManager.DeepCopy(schema) as SimpleGenericSchema <int>; Assert.AreNotSame(output, schema, "The serializer returned an instance of the same object"); Assert.AreEqual(schema.SomeValue, output.SomeValue, "The serialization didn't preserve the proper value"); }
public void SimpleBondSchemaSerializationTest() { var schema = new SimpleBondSchema { SomeValue = int.MaxValue }; var output = SerializationManager.RoundTripSerializationForTesting(schema); Assert.AreNotSame(output, schema, "The serializer returned an instance of the same object"); Assert.AreEqual(schema.SomeValue, output.SomeValue, "The serialization didn't preserve the proper value"); }
public async Task LCC_Dictionary() { string name1 = "Name" + random.Next(); string data1 = "Main"; const int NumLoops = 1000; var dict = new Dictionary <string, string>(); dict[name1] = data1; CallContext.LogicalSetData(name1, dict); var result1 = (Dictionary <string, string>)CallContext.LogicalGetData(name1); Assert.AreEqual(data1, result1[name1], "LCC.GetData-Main"); Task t = Task.Run(() => { var result2 = (Dictionary <string, string>)CallContext.LogicalGetData(name1); Assert.AreEqual(data1, result2[name1], "LCC.GetData-Task.Run"); Assert.AreSame(dict, result2, "Same object LCC.GetData-Task.Run"); }); await t; Task[] promises = new Task[NumLoops]; for (int i = 0; i < NumLoops; i++) { string str = i.ToString(CultureInfo.InvariantCulture); promises[i] = Task.Run(async() => { var dict2 = (Dictionary <string, string>)CallContext.LogicalGetData(name1); Assert.AreEqual(data1, dict2[name1], "LCC.GetData-Task.Run-Get-" + str); Assert.AreSame(dict, dict2, "Same object LCC.GetData-Task.Run-Get" + str); var dict3 = new Dictionary <string, string>(); dict3[name1] = str; CallContext.LogicalSetData(name1, dict3); await Task.Delay(10); var result3 = (Dictionary <string, string>)CallContext.LogicalGetData(name1); Assert.AreEqual(str, result3[name1], "LCC.GetData-Task.Run-Set-" + str); Assert.AreSame(dict3, result3, "Same object LCC.GetData-Task.Run-Set-" + str); Assert.AreNotSame(dict2, result3, "Differebntobject LCC.GetData-Task.Run-Set-" + str); }); } await Task.WhenAll(promises); }
public void ProtobuffSerializationTest_1_DirectProto() { AddressBook book = CreateAddressBook(); byte[] bytes; using (MemoryStream stream = new MemoryStream()) { book.WriteTo(stream); bytes = stream.ToArray(); } AddressBook restored = AddressBook.Parser.ParseFrom(bytes); Assert.AreNotSame(book, restored, "The serializer returned an instance of the same object"); Assert.AreEqual(1, restored.People.Count, "The serialization didn't preserve the same number of inner values"); Assert.AreEqual(book.People[0], restored.People[0], "The serialization didn't preserve the proper inner value"); Assert.AreEqual(book, restored, "The serialization didn't preserve the proper value"); }
public static void NotSame(object expected, object actual) { FrameworkAssert.AreNotSame(expected, actual); }
public static void AreNotSame(object expected, object actual, string message) { MSAssert.AreNotSame(expected, actual, message); }
public static void AreNotSame(object expected, object actual) { MSAssert.AreNotSame(expected, actual, string.Format("Expected\n{0}\nto differ from\n{1}", expected, actual)); }
public static void AreNotSame(object expected, object actual) { MSAssert.AreNotSame(expected, actual); }
public static void AreNotSame(object o1, object o2, string message) { MSAssert.AreNotSame(o1, o2, message); }
public static void AreNotSame(object o1, object o2) { MSAssert.AreNotSame(o1, o2); }