Exemplo n.º 1
0
        public void BenchmarkWithNoCacheMutable()
        {
            var mutable = new Mutable {
                Id = Guid.NewGuid(), Name = "name", Date = DateTime.Now
            };

            foreach (var _ in Enumerable.Range(0, Settings.IterationCount))
            {
                mutable.With(x => x.Name, "new name");
            }
        }
Exemplo n.º 2
0
        public void BenchmarkNativeMutable()
        {
            var mutable = new Mutable {
                Id = Guid.NewGuid(), Name = "name", Date = DateTime.Now
            };

            foreach (var _ in Enumerable.Range(0, Settings.IterationCount))
            {
                new Mutable {
                    Id = mutable.Id, Name = "new name", Date = mutable.Date
                };
            }
        }
Exemplo n.º 3
0
        public void WhenMutableWithNoCacheShouldCreateACopyWithANewValue()
        {
            var mutable = new Mutable {
                Id = Guid.NewGuid(), Name = "name", Date = DateTime.Now
            };

            var result = mutable.WithNoCache(x => x.Name, "new name");

            result.ShouldNotBe(mutable);
            result.Id.ShouldBe(mutable.Id);
            result.Date.ShouldBe(mutable.Date);
            result.Name.ShouldBe("new name");
        }
Exemplo n.º 4
0
        public void WhenMutableWithNoCacheShouldCreateACopyWithMultipleValues()
        {
            var mutable = new Mutable {
                Id = Guid.NewGuid(), Name = "name", Date = DateTime.Now
            };
            var newdate = mutable.Date.AddDays(1);

            var result = mutable.WithNoCache((x => x.Name, "new name"), (x => x.Date, newdate));

            result.ShouldNotBe(mutable);
            result.Id.ShouldBe(mutable.Id);
            result.Date.ShouldBe(newdate);
            result.Name.ShouldBe("new name");
        }