public async void create_should_return_null_if_model_is_invalid() { //arrange var invalidModel = new AppModel { Name = "invalidApp" }; //act var sut = new AppServiceBuilder().Build(); var task = await sut.Create(invalidModel); //assert Assert.Null(task); }
public async void create_should_return_with_app_id_if_model_is_valid() { //arrange var appModel = new AppModel { Name = "test", Url = "test.com", Description = "test_desc" }; var appRepository = new Mock <IRepository <App> >(); appRepository.Setup(x => x.Create(It.IsAny <App>())).Returns(new App()); appRepository.Setup(x => x.SaveChanges()).Returns(true); //act var sut = new AppServiceBuilder().WithAppRepository(appRepository.Object) .Build(); var appId = await sut.Create(appModel); //assert Assert.NotNull(appId); Assert.IsAssignableFrom <int>(appId); appRepository.Verify(x => x.Create(It.IsAny <App>()), Times.Once); appRepository.Verify(x => x.SaveChanges(), Times.AtLeastOnce); }