예제 #1
0
        public async Task TestCreateInvalidUser()
        {
            ACMDbContext    context         = ACMDbContextInMemoryFactory.InitializeContext();
            HomeownerSevice homeownerSevice = new HomeownerSevice(context);
            ACMUser         user            = new ACMUser {
                Email = "*****@*****.**"
            };
            await context.Users.AddAsync(user);

            await context.SaveChangesAsync();

            await Assert.ThrowsAsync <ACMException>(()
                                                    => homeownerSevice.Create("beer", "NOT [email protected]"));
        }
예제 #2
0
        public async Task TestCreateGoodData()
        {
            ACMDbContext    context         = ACMDbContextInMemoryFactory.InitializeContext();
            HomeownerSevice homeownerSevice = new HomeownerSevice(context);
            ACMUser         user            = new ACMUser {
                Email = "*****@*****.**"
            };
            await context.Users.AddAsync(user);

            await context.SaveChangesAsync();

            string id = await homeownerSevice.Create("beer", "*****@*****.**");

            Assert.Single(context.Ideas.ToList());
            Assert.Equal("beer", context.Ideas
                         .Where(x => x.Id == id)
                         .FirstOrDefault()
                         .Text);
            Assert.Equal("*****@*****.**", context.Ideas
                         .Where(x => x.Id == id)
                         .FirstOrDefault()
                         .User.Email);
        }