public async Task UpdateStausTestPositive(AccountRoles accountRole, OrderStatuses previousOrderStatus, OrderStatuses nextStatus)
        {
            //Arrange
            var owner = EntitiesCreationService.GetOwner();

            owner.HashedPassword = "******";
            var restaurant = EntitiesCreationService.GetRestaurant();

            owner.Restaurants = new List <Restaurant>()
            {
                restaurant
            };
            owner = await accountsRepository.AddAsync(owner);


            var account = EntitiesCreationService.GetOwner();

            account.HashedPassword = "******";
            account.Role           = accountRole;

            var order = EntitiesCreationService.GetOrder();

            var orderStatus = EntitiesCreationService.GetOrderStatus();

            orderStatus.Status  = previousOrderStatus;
            order.OrderStatuses = new List <OrderStatus>()
            {
                orderStatus
            };
            order.RestaurantId = owner.Restaurants[0].RestaurantId;
            account.Orders     = new List <Order>()
            {
                order
            };

            account = await accountsRepository.AddAsync(account);

            try
            {
                //Act
                await orderService.UpdateStaus(account.AccountId, account.Orders[0].EntityId, nextStatus);

                //Assert
                var statuses = ordersStatusRepository.GetAllStatusesForOrder(account.Orders[0].EntityId);
                Assert.Contains(statuses, s => s.Status == nextStatus);

                var orders = ordersRepository.GetAllOrdersForRegularUser(account.EntityId);
                Assert.Equal(orders[0].LatestOrderStatus, nextStatus);
            }
            finally
            {
                //Clear
                accountsRepository.Remove(account);
                accountsRepository.Remove(owner);
            }
        }
        public async Task TestBlockUser()
        {
            //Arrange
            var owner = EntitiesCreationService.GetOwner("BlockerOwner");

            owner.HashedPassword = "******";
            var user = EntitiesCreationService.GetUser("BlockingUser");

            user.HashedPassword = "******";
            user = await accountsRepository.AddAsync(user);

            owner = await accountsRepository.AddAsync(owner);

            try
            {
                //Act
                await accountsService.BanUser(owner.AccountId, user.UserName);

                //Assert
                var blockedUserOwners = blockedUsersRepository.BlokedUserOwners(user.AccountId);
                Assert.Contains(blockedUserOwners, buo => buo.OwnerId == owner.AccountId && buo.AccountId == user.AccountId);
            }
            finally
            {
                //Clean
                accountsRepository.Remove(user);
                accountsRepository.Remove(owner);
            }
        }
Example #3
0
 public async Task Handle(SignedUp notification, CancellationToken cancellationToken)
 {
     await _repo.AddAsync(new Domain.Account(notification.UserId, notification.Email));
 }
Example #4
0
 public async Task <Account> AddAccountAsync(Account skill)
 {
     return(await _skillsRepository.AddAsync(skill));
 }