Exemplo n.º 1
0
        public async Task DoesUserHaveItem_ShouldReturnTrue_IfCanBeMatchedOnUserAndItemName()
        {
            using (ApplicationDbContext context = ApplicationDbContextHelper.GetContext())
            {
                // Arrange
                IMapper mapper   = GetAutoMapperMapper();
                int     userId   = 1;
                int     itemId   = 1;
                string  itemName = "Longsword";
                context.Add(new Item {
                    Id = itemId, Name = itemName
                });
                context.Add(new UserItem {
                    ItemId = itemId, UserId = userId
                });
                context.SaveChanges();
                var userItemQueries = new UserItemQueries(context, mapper);

                // Act
                bool matchFound = await userItemQueries
                                  .DoesUserHaveItem(userId, new ItemDto { Name = itemName });

                // Assert
                Assert.True(matchFound);
            }
        }
Exemplo n.º 2
0
        public async Task DoesUserHaveItem_ShouldReturnFalse_IfNoUserItemCanBeMatched()
        {
            using (ApplicationDbContext context = ApplicationDbContextHelper.GetContext())
            {
                // Arrange
                IMapper mapper          = GetAutoMapperMapper();
                var     userItemQueries = new UserItemQueries(context, mapper);

                // Act
                bool matchFound = await userItemQueries
                                  .DoesUserHaveItem(1, new ItemDto { Id = 1, Name = "ExampleItem" });

                // Assert
                Assert.False(matchFound);
            }
        }