Пример #1
0
        public void GivenDatabaseError()
        {
            var ex = new Exception(Faker.Random.String());

            var database = CreateMock <IDatabase>();

            database
            .Setup(x => x.Fetch <Product>(It.IsNotNull <Sql>()))
            .Throws(ex);

            GetDependency <INPocoDatabaseFactory>().Setup(x => x.CreateDatabase()).Returns(database.Object);

            Should.Throw <DataException>(() => TestInstance.List())
            .InnerException.ShouldBe(ex);
        }
Пример #2
0
        public void GivenAtLeastOneProductInDatabase()
        {
            var product = new Product
            {
                Id            = Faker.Random.Guid(),
                Name          = Faker.Random.String(),
                Description   = Faker.Random.String(),
                DeliveryPrice = Faker.Random.Decimal()
            };

            var database = CreateMock <IDatabase>();

            database
            .Setup(x => x.Fetch <Product>(It.IsNotNull <Sql>()))
            .Returns(new List <Product> {
                product
            });

            GetDependency <INPocoDatabaseFactory>().Setup(x => x.CreateDatabase()).Returns(database.Object);

            TestInstance.List().ShouldContain(product);
        }