Пример #1
0
        public void AssertRun_Given_ClassWithStaticFieldConcurrencyIssue_Should_ThrowException()
        {
            var instance = new ClassWithStaticFieldConcurrencyIssue();
            var finder   = new ConcurrencyChecker(instance);

            instance.ChangeNameTo("John");

            Assert.Throws <ConcurrencyException>(() => finder.Assert(5,
                                                                     () => instance.ChangeNameTo("Jane"),
                                                                     () => instance.ChangeNameTo("Peter")));
        }
Пример #2
0
        public void Run_Given_ClassWithStaticFieldConcurrencyIssue_Should_ReturnReportWithIssue()
        {
            var instance = new ClassWithStaticFieldConcurrencyIssue();
            var finder   = new ConcurrencyChecker(instance);

            instance.ChangeNameTo("John");
            var report = finder.Run(5, () => instance.ChangeNameTo("Jane"), () => instance.ChangeNameTo("Peter"));

            Console.WriteLine(report);

            Assert.IsNotNull(report);
            Assert.IsTrue(report.Contains(
                              "ClassWithStaticFieldConcurrencyIssue->_name: Reference and actual number of value changes does not match."));
            Assert.IsTrue(report.Contains(
                              "ClassWithStaticFieldConcurrencyIssue->_name: Reference Value Changes: \n0: String = John\n1: String = Jane"));
            Assert.IsTrue(report.Contains(
                              "ClassWithStaticFieldConcurrencyIssue->_name: Actual Value Changes: \n0: String = John\n1: String = Jane\n2: String = Peter"));
        }