Exemple #1
0
        public async Task TestCreateARegistrationCodeInvalidApartmentNumber()
        {
            ACMDbContext context     = ACMDbContextInMemoryFactory.InitializeContext();
            CodeService  codeService = new CodeService(context);
            Apartment    apartment1  = new Apartment {
                Number = 1
            };
            await context.Apartments.AddAsync(apartment1);

            await context.SaveChangesAsync();

            await Assert.ThrowsAsync <ACMException>(() => codeService.CreateARegistrationCode("0"));
        }
Exemple #2
0
        public async Task TestCreateARegistrationCodeGoodData()
        {
            ACMDbContext context     = ACMDbContextInMemoryFactory.InitializeContext();
            CodeService  codeService = new CodeService(context);
            Apartment    apartment1  = new Apartment {
                Number = 1
            };
            await context.Apartments.AddAsync(apartment1);

            await context.SaveChangesAsync();

            CodeDTO code = await codeService.CreateARegistrationCode("1");

            Assert.Single(context.RegistrationCodes.ToList());
            Assert.Equal(1, context.RegistrationCodes.FirstOrDefault().Apartment.Number);
            Assert.Equal(code.Code, context.RegistrationCodes.FirstOrDefault().Code);
        }