예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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"));
        }