public async Task Handle_guid_is_empty() { //arrange var handler = new RegistrationCommandHandler(mediatorMock.Object, loggerMock.Object, claimsManagerMock.Object); IdentifiedCommand <RegistrationCommand, bool> request = new IdentifiedCommand <RegistrationCommand, bool>(new RegistrationCommand(), Guid.Empty); CancellationToken token = default(System.Threading.CancellationToken); //act //assert await Assert.ThrowsAsync <ArgumentException>(() => handler.Handle(request, token)); }
public async Task Handle_invalid_user_data(string customerId, string customerName, string customerEmail, string customerPhone, string customerAddress, string customerAdditionalAddress, string customerDistrict, string customerCity, string customerState, string customerZipCode) { //arrange var handler = new RegistrationCommandHandler(mediatorMock.Object, loggerMock.Object, claimsManagerMock.Object); RegistrationCommand command = new RegistrationCommand(customerId, customerName, customerEmail, customerPhone, customerAddress, customerAdditionalAddress, customerDistrict, customerCity, customerState, customerZipCode); IdentifiedCommand <RegistrationCommand, bool> request = new IdentifiedCommand <RegistrationCommand, bool>(command, Guid.NewGuid()); CancellationToken token = default(System.Threading.CancellationToken); //act //assert await Assert.ThrowsAsync <InvalidUserDataException>(() => handler.Handle(request, token)); }
public async Task Handle_success() { //arrange claimsManagerMock .Setup(c => c.AddUpdateClaim(It.IsAny <string>(), It.IsAny <IDictionary <string, string> >())) .Returns(Task.CompletedTask) .Verifiable(); var handler = new RegistrationCommandHandler(mediatorMock.Object, loggerMock.Object, claimsManagerMock.Object); RegistrationCommand command = new RegistrationCommand("customerId", "customerName", "*****@*****.**", "phone", "address", "additionalAddress", "district", "city", "state", "12345-678"); IdentifiedCommand <RegistrationCommand, bool> request = new IdentifiedCommand <RegistrationCommand, bool>(command, Guid.NewGuid()); CancellationToken token = default(CancellationToken); //act var result = await handler.Handle(request, token); //assert Assert.True(result); claimsManagerMock.Verify(); }