Пример #1
0
        public async Task ContainsByUserIdAndShoppingListIdAsync_WithNonExistentUserIdAndShoppingListId_ShouldReturnCorrectResult()
        {
            var errorMessagePrefix = "UserShoppingListService ContainsByUserIdAndShoppingListIdAsync() method does not work properly.";

            // Arrange
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();
            var userShoppingListRepository = new EfRepository <UserShoppingList>(context);
            var userShoppingListService    = new UserShoppingListService(userShoppingListRepository);

            await this.SeedDataAsync(context);

            var nonExistentUserId         = Guid.NewGuid().ToString();
            var nonExistentShoppingListId = Guid.NewGuid().ToString();

            // Act
            var result = await userShoppingListService
                         .ContainsByUserIdAndShoppingListIdAsync(nonExistentUserId, nonExistentShoppingListId);

            // Assert
            Assert.False(result, errorMessagePrefix + " " + "Returns true.");
        }
Пример #2
0
        public async Task ContainsByUserIdAndShoppingListIdAsync_WithExistentUserIdAndShoppingListId_ShouldReturnCorrectResult()
        {
            var errorMessagePrefix = "UserShoppingListService ContainsByUserIdAndShoppingListIdAsync() method does not work properly.";

            // Arrange
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();
            var userShoppingListRepository = new EfRepository <UserShoppingList>(context);
            var userShoppingListService    = new UserShoppingListService(userShoppingListRepository);

            await this.SeedDataAsync(context);

            var userId         = context.Users.First(x => x.FullName == "User 1").Id;
            var shoppingListId = context.ShoppingLists.First(x => x.Ingredients == "Ingredients 1").Id;

            // Act
            var result = await userShoppingListService
                         .ContainsByUserIdAndShoppingListIdAsync(userId, shoppingListId);

            // Assert
            Assert.True(result, errorMessagePrefix + " " + "Returns false.");
        }