public async Task CreateNotifikationCommand_CustomerDataCreateOnDatabase() { //Arange var writeIRepositoryMoq = new Mock <IWriteIRepository>(); var readRepositoryMoq = new Mock <IReadRepository>(); var config = new MapperConfiguration(cfg => cfg.AddProfile <NotifikationProfile>()); IMapper mapper = config.CreateMapper(); var command = new CreateNotifikationCommand() { Notifikation = new NotifikatItemDTO() { Message = "test", User = new UserDTO() { Email = "*****@*****.**", Name = "test" } } }; var handler = new CreateNotifikationCommandHandler(writeIRepositoryMoq.Object, readRepositoryMoq.Object, mapper); //Act NotifikatItemDTO x = await handler.Handle(command, new System.Threading.CancellationToken()); //Asert writeIRepositoryMoq.Verify(x => x.Add <NotifikationEntity>(It.IsAny <NotifikationEntity>())); }
public async Task CreateNotifikationCommand_CustomerDataReturnExistsNotifikatInfrastructureException() { //Arange var writeIRepositoryMoq = new Mock <IWriteIRepository>(); var readRepositoryMoq = new Mock <IReadRepository>(); readRepositoryMoq.Setup(f => f.Contains(It.IsAny <ISpecification <NotifikationEntity> >())) .Returns(true); //Contains var config = new MapperConfiguration(cfg => cfg.AddProfile <NotifikationProfile>()); IMapper mapper = config.CreateMapper(); var command = new CreateNotifikationCommand() { Notifikation = new NotifikatItemDTO() { Message = "test", User = new UserDTO() { Email = "*****@*****.**", Name = "test" } } }; var handler = new CreateNotifikationCommandHandler(writeIRepositoryMoq.Object, readRepositoryMoq.Object, mapper); //Act Func <Task <NotifikatItemDTO> > act = () => handler.Handle(command, new System.Threading.CancellationToken()); //Asert await act.Should().ThrowAsync <NoExistsNotifikatInfrastructureException>(); }
public async Task Post_EndpointsReturnSuccessAndCorrectStatusCodeMethodNotAllowed(string url) { // Arrange var client = this._factory.CreateClient(); // Act var model = new CreateNotifikationCommand() { Notifikation = new NotifikatItemDTO() { Message = string.Empty } }; var stringContent = new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, stringContent); // Assert Xunit.Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); }
public async Task <ActionResult> Post([FromBody] CreateNotifikationCommand notifikationModel) { return(Created(string.Empty, await mediator.Send(notifikationModel))); }