Пример #1
0
        public async Task SetInvitationKeyAsUsed_passedUsedKey_returnTrue()
        {
            // arrange
            var invKeyDate  = new DateTime(2005, 4, 2, 21, 37, 00);
            var firstInvKey = new InvitationKey
            {
                Id           = Constants.FIRST_INV_KEY_ID,
                InviterId    = Constants.APP_ADMIN_ID,
                CreatedAt    = invKeyDate,
                Key          = "1234567890",
                UsedByUserId = 1
            };

            _context.InvitationKeys.Add(firstInvKey);
            _context.SaveChanges();

            // act
            await _invitationKeyService.SetInvitationKeyAsUsed("1234567890", new User()
            {
                Id = 2
            });

            // assert
            Assert.IsTrue(await _context.InvitationKeys
                          .AnyAsync(x => x.UsedByUserId == 2));
        }
Пример #2
0
        public void SeedData()
        {
            using var serviceScope = _scopeFactory.CreateScope();
            using var context      = serviceScope.ServiceProvider.GetService <AppDbContext>();

            if (!context.Users.Any())
            {
                var appAdmin = new User
                {
                    Id        = 1,
                    Login     = "******",
                    Password  = "******",
                    Email     = "*****@*****.**",
                    FirstName = "Floiir",
                    LastName  = "Admin"
                };
                context.Users.Add(appAdmin);
            }

            if (!context.InvitationKeys.Any())
            {
                var invKeyDate  = new DateTime(2005, 4, 2, 21, 37, 00);
                var firstInvKey = new InvitationKey
                {
                    Id        = Constants.FIRST_INV_KEY_ID,
                    InviterId = Constants.APP_ADMIN_ID,
                    CreatedAt = invKeyDate,
                    Key       = "1234567890",
                };
                context.InvitationKeys.Add(firstInvKey);
            }

            context.SaveChanges();
        }
Пример #3
0
        public async Task ValidateAndReturnObject_passedValidKey_returnTrue()
        {
            // arrange
            var invKeyDate  = new DateTime(2005, 4, 2, 21, 37, 00);
            var firstInvKey = new InvitationKey
            {
                Id        = Constants.FIRST_INV_KEY_ID,
                InviterId = Constants.APP_ADMIN_ID,
                CreatedAt = invKeyDate,
                Key       = "1234567890",
            };

            _context.InvitationKeys.Add(firstInvKey);
            _context.SaveChanges();

            // act
            var keyCheck = await _invitationKeyService.ValidateAndReturnObject("1234567890");

            // assert
            Assert.IsTrue(keyCheck.Succeed);
        }