public async Task TestExceptionIsThrownShouldReturnErrorCode(Type exceptionType, ResponseCode code) { var exception = exceptionType == typeof(MessengerException) ? new MessengerException(code) : new Exception(); var interactor = new CreateUserInteractor(new ExceptionMessenger(exception), new InMemoryAddressGenerator()); var response = await interactor.ExecuteAsync(new CreateUserRequest { Seed = Seed.Random() }); Assert.AreEqual(code, response.Code); }
public async Task TestCreatedUserDataIsSentViaMessengerAndReturned() { var seed = Seed.Random(); var interactor = new CreateUserInteractor(new InMemoryMessenger(), new InMemoryAddressGenerator()); var response = await interactor.ExecuteAsync(new CreateUserRequest { Seed = seed }); Assert.AreEqual(ResponseCode.Success, response.Code); Assert.AreEqual(seed.Value, response.PublicKeyAddress.Value); Assert.IsNotNull(response.RequestAddress); Assert.IsNotNull(response.NtruKeyPair); }
public async Task TestCreatedUserDataIsSentSignedAndReturned() { var seed = Seed.Random(); var inMemoryMessenger = new InMemoryMessenger(); var interactor = new CreateUserInteractor( inMemoryMessenger, new InMemoryAddressGenerator(), new EncryptionStub(), new SignatureGeneratorStub()); var response = await interactor.ExecuteAsync(new CreateUserRequest { Seed = seed }); Assert.AreEqual(ResponseCode.Success, response.Code); Assert.AreEqual(seed.Value, response.PublicKeyAddress.Value); Assert.IsNotNull(response.RequestAddress); Assert.IsNotNull(response.NtruKeyPair); Assert.IsTrue(inMemoryMessenger.SentMessages[0].Payload.Value.Contains("STUBFRAGMENTSIGNATURE")); }