コード例 #1
0
        public async Task TestAllGoodData()
        {
            ACMDbContext    context         = ACMDbContextInMemoryFactory.InitializeContext();
            HomeownerSevice homeownerSevice = new HomeownerSevice(context);
            ACMUser         user            = new ACMUser {
                Email = "*****@*****.**", FullName = "gosho"
            };
            Idea idea1 = new Idea {
                Id = "1", User = user, Text = "idea1"
            };
            Idea idea2 = new Idea {
                Id = "2", User = user, Text = "idea2"
            };
            await context.Users.AddAsync(user);

            await context.Ideas.AddAsync(idea1);

            await context.Ideas.AddAsync(idea2);

            await context.SaveChangesAsync();

            var list = homeownerSevice.All();

            Assert.Equal(2, list.Count);
            Assert.Equal("1", list[1].Id);
            Assert.Equal("idea1", list[1].Text);
            Assert.Equal("*****@*****.**", list[1].UserName);
            Assert.Equal("gosho", list[1].Name);
            Assert.Equal("2", list[0].Id);
            Assert.Equal("idea2", list[0].Text);
            Assert.Equal("*****@*****.**", list[0].UserName);
            Assert.Equal("gosho", list[0].Name);
        }
コード例 #2
0
        public void TestAllEmptyTable()
        {
            ACMDbContext    context         = ACMDbContextInMemoryFactory.InitializeContext();
            HomeownerSevice homeownerSevice = new HomeownerSevice(context);
            var             list            = homeownerSevice.All();

            Assert.Empty(list);
        }