예제 #1
0
        public void DeleteContactMessageShouldDeleteMessageCorrect()
        {
            var options = new DbContextOptionsBuilder <WAGDbContext>()
                          .UseInMemoryDatabase(databaseName: "Delete_Message_Db")
                          .Options;

            var dbContext = new WAGDbContext(options);

            var service = new HomeService(dbContext, null);

            string userId = Guid.NewGuid().ToString();

            var message = new ContactMessage()
            {
                Title     = "Test title",
                TextBody  = "Test textBody",
                WAGUserId = userId,
            };

            dbContext.ContactMessages.Add(message);
            dbContext.SaveChanges();

            var messageId = dbContext.ContactMessages.LastOrDefault().Id;

            service.DeleteContactMessage(messageId);

            Assert.Null(dbContext.ContactMessages.FirstOrDefault(m => m.Id == messageId));
        }