public void Test_That_ToImmutable_Returns_New_Instance()
        {
            var testClass = new ImmutableBuilder <TestClass>();
            var immutable = testClass.ToImmutable();

            testClass.ToImmutable().ShouldNotBe(immutable);
        }
예제 #2
0
 /// <summary>
 /// Creates a new Immutable builder with the supplied enclosed type instance.
 /// </summary>
 /// <param name="self">The instance of the enclosed type to use.</param>
 /// <returns>A new ImmutableBuilder instance.</returns>
 public static ImmutableBuilder <T> Create <T>(T self) where T : new()
 {
     return(ImmutableBuilder <T> .Create(self));
 }
예제 #3
0
        public void ImmutableBuilder_Microbenchmark()
        {
            var stopwatch = new Stopwatch();
            var testClass = new TestClass();
            var testClassImmutableBuilder = new ImmutableBuilder<TestClass>();

            stopwatch.Start();
            for (var i = 0; i < 100000; i++)
            {
                testClass.Test = i;
            }
            stopwatch.Stop();

            var setterTime = stopwatch.ElapsedMilliseconds;

            stopwatch.Reset();

            testClassImmutableBuilder.Modify(x => x.Test = 1);

            stopwatch.Start();
            for (var i = 0; i < 100000; i++)
            {
                testClassImmutableBuilder.Modify(x => x.Test = 1);
            }
            stopwatch.Stop();

            var immutableTime = stopwatch.ElapsedMilliseconds;
        }
예제 #4
0
        public void Test_That_ToImmutable_Returns_New_Instance()
        {
            var testClass = new ImmutableBuilder<TestClass>();
            var immutable = testClass.ToImmutable();

            Assert.NotSame(testClass, immutable);
        }