public async Task Remove_Success() { //Arrange var templatesRepository = new Mock<ITemplatesRepository>(); var templatesManager = new TemplatesManager(templatesRepository.Object); var searchingName = "tests template 1"; var searchingLanguage = new CultureInfo("en"); var entities = new List<Template> { new Template { Name = searchingName, Subject = "tests subject 1", HtmlBodyTemplate = "Hi my friend :)", PlainBodyTemplate = "test plain", Priority = EmailMessagePriority.Normal, Tag = "test tag", Language = "es", FromAddress = "*****@*****.**", CreatedDateTime = DateTime.UtcNow }, new Template { Name = searchingName, Subject = "tests subject 2", HtmlBodyTemplate = "Hi my friend :)", PlainBodyTemplate = "test plain", Priority = EmailMessagePriority.Normal, Tag = "test tag)", Language = searchingLanguage.Name, FromAddress = "*****@*****.**", CreatedDateTime = DateTime.UtcNow } }; Template removedTemplate = null; //Expect templatesRepository .Setup(x => x.GetQuerable()) .Returns(new AsyncEnumerable<Template>(entities)); templatesRepository .Setup(x => x.RemoveAsync(It.IsNotNull<Template>())) .Callback<Template>(template => { removedTemplate = template; }) .Returns(Task.CompletedTask); //Act await templatesManager.Remove(searchingName, searchingLanguage); //Assert Assert.IsNotNull(removedTemplate); Assert.AreEqual(searchingName, removedTemplate.Name); Assert.AreEqual(searchingLanguage.Name, removedTemplate.Language); Assert.AreEqual(entities[1].Subject, removedTemplate.Subject); Assert.AreEqual(entities[1].HtmlBodyTemplate, removedTemplate.HtmlBodyTemplate); Assert.AreEqual(entities[1].PlainBodyTemplate, removedTemplate.PlainBodyTemplate); Assert.AreEqual(entities[1].Priority, removedTemplate.Priority); Assert.AreEqual(entities[1].Tag, removedTemplate.Tag); Assert.AreEqual(entities[1].FromAddress, removedTemplate.FromAddress); Assert.AreEqual(entities[1].CreatedDateTime, removedTemplate.CreatedDateTime); //Verify templatesRepository.VerifyAll(); }