Ejemplo n.º 1
0
        public async Task Get_DoestNotReturnObject()
        {
            byte[] serverResponse = SerializationUtils.Serialize(RequestStatusCode.NotFound);
            var    connectionMock = Substitute.For <IConnection>();

            connectionMock.SendAsync(Arg.Any <GetRequest>())
            .Returns(SerializationUtils.Serialize(serverResponse));

            KronosConfig  config = LoadTestConfiguration();
            IKronosClient client = new KronosClient(config, endpoint => connectionMock);

            byte[] response = await client.GetAsync("key");

            Assert.Null(response);
            await connectionMock.Received(1).SendAsync(Arg.Any <GetRequest>());
        }
Ejemplo n.º 2
0
        public void Kronos()
        {
            Parallel.For(0, Clients, _ =>
            {
                string key = Prepare.Key();

                KronosClient.InsertAsync(key, _data, null)
                .GetAwaiter().GetResult();

                KronosClient.GetAsync(key)
                .GetAwaiter().GetResult();

                KronosClient.DeleteAsync(key)
                .GetAwaiter().GetResult();
            });
        }
Ejemplo n.º 3
0
        public async Task Get_ReturnsObject()
        {
            const string word = "lorem ipsum";

            byte[] package = SerializationUtils.Serialize(word);

            var connectionMock = Substitute.For <IConnection>();

            connectionMock.SendAsync(Arg.Any <GetRequest>())
            .Returns(SerializationUtils.Serialize(package));

            KronosConfig  config = LoadTestConfiguration();
            IKronosClient client = new KronosClient(config, endpoint => connectionMock);

            byte[] response = await client.GetAsync("key");

            string responseString = SerializationUtils.Deserialize <string>(response);

            Assert.Equal(responseString, word);
            await connectionMock.Received(1).SendAsync(Arg.Any <GetRequest>());
        }