Example #1
0
        public async Task TestCreateInvalidUser()
        {
            ACMDbContext context   = ACMDbContextInMemoryFactory.InitializeContext();
            IPService    iPService = new IPService(context);
            ACMUser      user      = new ACMUser {
                UserName = "******", FullName = "gosho"
            };
            await context.Users.AddAsync(user);

            await context.SaveChangesAsync();

            IpDTO model = new IpDTO(null, "123.123.123...");
            await Assert.ThrowsAsync <ACMException>(() => iPService.Create(model));
        }
Example #2
0
        public async Task TestCreateGoodData()
        {
            ACMDbContext context   = ACMDbContextInMemoryFactory.InitializeContext();
            IPService    iPService = new IPService(context);
            ACMUser      user      = new ACMUser {
                UserName = "******", FullName = "gosho"
            };
            await context.Users.AddAsync(user);

            await context.SaveChangesAsync();

            IpDTO  model  = new IpDTO(user, "123.123.123...");
            string output = await iPService.Create(model);

            Assert.Single(context.IPs.ToList());
            Assert.True(context.IPs.Any(x => x.Id == output));
            Assert.Equal("*****@*****.**", context.IPs.FirstOrDefault().User.UserName);
            Assert.Equal("123.123.123...", context.IPs.FirstOrDefault().IpString);
        }