public void UpdateExampleEntity_WithInvalidOwner_ShouldThrowUserAccessException() { // Arrange var sut = new UpdateExampleEntityCommandHandler(this.Context); // Act var cmd = new UpdateExampleEntityCommand { EntityId = 3, Description = "ExampleEntity 3 - Edited", UserId = "0001" }; Should.Throw <UserAccessViolation>(async() => { await sut.Handle(cmd, CancellationToken.None); }); }
public void EntityId_ShouldThrowNotFoundException() { // Arrange var sut = new UpdateExampleEntityCommandHandler(this.Context); // Act var cmd = new UpdateExampleEntityCommand { EntityId = 10, Description = "ExampleEntity 3 - Edited", UserId = "0001" }; Should.Throw <NotFoundException>(async() => { await sut.Handle(cmd, CancellationToken.None); }); }
public async Task UpdateExampleEntity_WithCorrectOwner_ShouldUpdateExampleEntityDetails() { // Arrange var sut = new UpdateExampleEntityCommandHandler(this.Context); // Act var cmd = new UpdateExampleEntityCommand { EntityId = 1, Description = "ExampleEntity 1 - Edited", UserId = "0001" }; await sut.Handle(cmd, CancellationToken.None); var updatedExampleEntity = this.Context.ExampleEntities.FirstOrDefault(c => c.Id == cmd.EntityId); // Assert updatedExampleEntity.ShouldNotBeNull(); updatedExampleEntity.Description.ShouldBe(cmd.Description); }