Пример #1
0
            public void Can_call_With_on_type_with_only_property_setters(
                string sourceId, string sourceName, int?sourceAge,
                string withId, string withName, int?withAge,
                string expectedId, string expectedName, int?expectedAge)
            {
                // Arrange
                var source = new SourceWithSetters
                {
                    Id   = sourceId,
                    Name = sourceName,
                    Age  = sourceAge
                };

                // Act
                var result = source
                             .With(_ => _.Id, withId)
                             .With(_ => _.Name, withName)
                             .With(_ => _.Age, withAge);

                // Assert
                result.Should().BeOfType <SourceWithSetters>();
                result.Age.Should().Be(expectedAge);
                result.Id.Should().Be(expectedId);
                result.Name.Should().Be(expectedName);
            }
Пример #2
0
        public void Calling_With_creates_a_new_instance()
        {
            // Arrange
            var source = new SourceWithSetters();

            // Act
            var result = source.With(s => s.Id, "T");

            // Assert
            result.GetHashCode().Should().NotBe(source.GetHashCode());
        }