示例#1
0
        public async void Will_Fail_With_InvalidOperationException()
        {
            var customerQueries = Substitute.For<ICustomerQueries>();

            var customers = new Customer[] 
            {
                new Customer {Id=1, Country="USA", Name="Michael", Address="Address 1" },
                new Customer {Id=2, Country="ROC", Name="Jane", Address="Address 2" },
            };

            customerQueries.GetCustomersQuery().Returns(customers.AsQueryable());

            var demo = new Demo(customerQueries);
            var result = await demo.Run();

            result.Length.Should().Be(2);
        }
示例#2
0
        public async void Should_Get_Customers()
        {
            var customerQueries = Substitute.For<ICustomerQueries>();

            var customers = new Customer[] 
            {
                new Customer {Id=1, Country="USA", Name="Michael", Address="Address 1" },
                new Customer {Id=2, Country="ROC", Name="Jane", Address="Address 2" },
            };

            var customerQuery = 
                Substitute
                    .For<DbSet<Customer>, IQueryable<Customer>, IDbAsyncEnumerable<Customer>>()
                    .SetupData(customers);

            customerQueries.GetCustomersQuery().Returns(customerQuery);

            var demo = new Demo(customerQueries);
            var result = await demo.Run();

            result.Length.Should().Be(2);
            result[0].Name.Should().Be(customers[0].Name);
            result[1].Name.Should().Be(customers[1].Name);
        }