Exemple #1
0
        public async void should_correctly_do_a_full_send_then_receive_in_single_pipeline()
        {
            var filename = "example_save.json";

            _testOutputHelper.WriteLine("{0}/{1}", Environment.CurrentDirectory, filename);

            var serializer          = new JsonSerializer();
            var deserializer        = new JsonDeserializer();
            var memoryEndpoint      = new InMemoryEndpoint();
            var encryptor           = new AesEncryptor("some-password");
            var encryptionProcessor = new EncryptDataProcessor(encryptor);
            var decryptionProcessor = new DecryptDataProcessor(encryptor);

            var saveToBinaryFilePipeline = new PipelineBuilder()
                                           .StartFromInput()
                                           .SerializeWith(serializer)
                                           .ProcessWith(encryptionProcessor)
                                           .ThenSendTo(memoryEndpoint)
                                           .ThenReceiveFrom(memoryEndpoint)
                                           .ProcessWith(decryptionProcessor)
                                           .DeserializeWith <GameData>(deserializer)
                                           .Build();

            var dummyData   = GameData.CreateRandom();
            var outputModel = await saveToBinaryFilePipeline.Execute(dummyData);

            Assert.AreEqual(dummyData, outputModel);
        }
        private static ISignClient CreateOrganizationClient()
        {
            var credentials = new InMemoryCredentials(ClientId, ClientSecret);
            var uri         = new InMemoryEndpoint(Endpoint);
            var response    = new ApiResponse(new HttpClientAdapter());

            return(new SignClient(
                       new OrganizationApiRequest(
                           credentials,
                           uri,
                           new CurrentTimeProvider()),
                       response));
        }
        private static ISignClient CreatePartnerClient(string currentBusinessI)
        {
            var credentials = new InMemoryCredentials(ClientId, ClientSecret);
            var uri         = new InMemoryEndpoint(Endpoint);

            var response     = new ApiResponse(new HttpClientAdapter());
            var partnerToken = new MemoryCachedPartnerAccessToken(
                new PartnerAccessToken(credentials, uri, response, new AllScopes()),
                new CurrentTimeProvider());
            var organizationToken = new MemoryCachedOrganizationToken(new OrganizationToken(uri, partnerToken, response));

            return(new SignClient(
                       new PartnerApiRequest(
                           organizationToken,
                           partnerToken,
                           uri,
                           new InMemoryOrganization(currentBusinessI)),
                       response));
        }