public void TestGetComponent12() { IMutableComponentContainer container = new ComponentContainerImpl(); container.Register(typeof(TestClass1), "TestClass1"); container.Register(typeof(TestClass5)); Console.WriteLine("Test12 Start"); TestClass5 test = (TestClass5)container.GetComponent(typeof(TestClass5)); test.Print(); Console.WriteLine("Test12 End"); }
public void Autosubscribe_GenericParameter() { using (var wait = new ManualResetEvent(false)) { var target = new MessageBus(); var obj = new TestClass5(wait); var token = target.AutoWireupSubscribers(obj); target.Publish("test"); wait.WaitOne(2000).Should().Be(true); obj.Value.Should().Be("test"); } }
public void HappyPathAfter() { var results = new List <ValidationResult>(); var request = new TestClass5 { Start = DateTime.Today, End = DateTime.Today.AddDays(-1) }; var context = new ValidationContext(request); var isValid = new DataAnnotationsValidator(new DottedNumberCollectionPropertyNamingStrategy()).TryValidateObjectRecursive(request, results, context); Assert.IsFalse(isValid); Assert.AreEqual("End must be after Start", results[0].ErrorMessage); Assert.AreEqual(1, results[0].MemberNames.Count()); }
public void TestBuildWithMultipleConstructors() { var property = new TestClass(); SimpleIoc.Default.Reset(); SimpleIoc.Default.Register<ITestClass>(() => property); SimpleIoc.Default.Register<TestClass5>(); var instance1 = new TestClass5(); Assert.IsNotNull(instance1); Assert.IsNull(instance1.MyProperty); var instance2 = SimpleIoc.Default.GetInstance<TestClass5>(); Assert.IsNotNull(instance2); Assert.IsNotNull(instance2.MyProperty); Assert.AreSame(property, instance2.MyProperty); }
public void ClassIsEqualByPropertyValue() { object o1, o2; o1 = null; o2 = null; Assert.IsTrue(Energy.Base.Class.IsEqualByPropertyValue(o1, o2, true, false, false)); o1 = new TestClass5(); Assert.IsFalse(Energy.Base.Class.IsEqualByPropertyValue(o1, o2, true, false, false)); o2 = new TestClass5(); Assert.IsTrue(Energy.Base.Class.IsEqualByPropertyValue(o1, o2, true, false, false)); o2 = new TestClass6(); Assert.IsTrue(Energy.Base.Class.IsEqualByPropertyValue(o1, o2, true, false, false)); ((TestClass5)o1).number = "1234"; ((TestClass6)o2).Number = 1234; Assert.IsTrue(Energy.Base.Class.IsEqualByPropertyValue(o1, o2, true, false, false)); Assert.IsTrue(Energy.Base.Class.IsEqualByPropertyValue(o1, o2, false, false, false)); }
public void TestBuildWithMultipleConstructors() { var property = new TestClass1(); SimpleIoc.Default.Reset(); SimpleIoc.Default.Register <ITestClass>(() => property); SimpleIoc.Default.Register <TestClass5>(); var instance1 = new TestClass5(); Assert.IsNotNull(instance1); Assert.IsNull(instance1.MyProperty); var instance2 = SimpleIoc.Default.GetInstance <TestClass5>(); Assert.IsNotNull(instance2); Assert.IsNotNull(instance2.MyProperty); Assert.AreSame(property, instance2.MyProperty); }