コード例 #1
0
        public void BuilderBaseTests_BuildWithPropertiesAction()
        {
            var book = MockBook.CreateBuilder().SetTitle("Hello World").Build();

            Assert.NotNull(book);
            Assert.Equal("Hello World", book.Title);
        }
コード例 #2
0
        public void BuilderBaseTests_BuildConstructorEntity_ValidateBaseObject()
        {
            var ex = Assert.Throws <ArgumentException>(() => MockBook.CreateBuilder(new MockBook {
                ISBN = "111"
            }));

            Assert.Equal("Bad ISBN", ex.Message);
        }
コード例 #3
0
        public void BuilderBaseTests_BuildEmpty_DifferentObjects()
        {
            var builder = MockBook.CreateBuilder();

            var newBook1 = builder.Build();

            var newBook2 = builder.Build();

            Assert.NotNull(newBook1);
            Assert.NotNull(newBook2);
            Assert.Null(newBook1.Title);
            Assert.Null(newBook2.Title);
            Assert.NotEqual(newBook1, newBook2);
        }
コード例 #4
0
        public void BuilderBaseTests_BuildConstructorEntity_DifferentObjects()
        {
            var builder = MockBook.CreateBuilder(new MockBook {
                ISBN = "112"
            });

            var newBook1 = builder.Build();

            var newBook2 = builder.Build();

            Assert.NotNull(newBook1);
            Assert.NotNull(newBook2);
            Assert.NotEqual(newBook1, newBook2);
            Assert.Equal(newBook1.ISBN, newBook2.ISBN);
        }
コード例 #5
0
        public void BuilderBaseTests_BuildWithNullEntity()
        {
            var ex = Assert.Throws <ArgumentNullException>(() => MockBook.CreateBuilder(null));

            Assert.Equal("Value cannot be null.\r\nParameter name: baseEntity", ex.Message);
        }