예제 #1
0
        public async Task getTraderInformationWhenCallingQueryWithTraderID()
        {
            string results = await hyperledgerService.InvokeGet(HyperledgerConsts.TraderQueryURL("TRADER1"));

            Trader trader = JsonConvert.DeserializeObject <Trader>(results);

            Assert.AreEqual("TRADER1", trader.traderId);
        }
        public async Task Login_Method_for_client_should_set_username()
        {
            mockBlockService.Setup(m => m.InvokeGet(HyperledgerConsts.TraderQueryURL(TestJsonObjectConsts.trader1ID)))
            .ReturnsAsync(TestJsonObjectConsts.trader1);
            mockBlockService.Setup(m => m.InvokePostAuthentication(FlaskConsts.LoginUrl, JsonConvert.SerializeObject(user)))
            .ReturnsAsync(TestJsonObjectConsts.trader1AuthenticationMessage);

            await clientWithMock.Login(user);

            Assert.AreEqual(TestJsonObjectConsts.trader1ID, clientWithMock.thisTrader.traderId);
        }
예제 #3
0
 public async Task WhenCallingInvalidUserIDReturnHttpException()
 {
     try
     {
         string results = await hyperledgerService.InvokeGet(HyperledgerConsts.TraderQueryURL("Invalid"));
     }
     catch (HttpRequestException)
     {
         Assert.IsTrue(true);
     }
 }
        public async Task Successful_login_will_set_trader_object_to_serialized_json()
        {
            mockBlockService.Setup(m => m.InvokeGet(HyperledgerConsts.TraderQueryURL(TestJsonObjectConsts.trader1ID)))
            .ReturnsAsync(TestJsonObjectConsts.trader1);
            mockBlockService.Setup(m => m.InvokePostAuthentication(FlaskConsts.LoginUrl, JsonConvert.SerializeObject(user)))
            .ReturnsAsync(TestJsonObjectConsts.trader1AuthenticationMessage);
            Trader expectedTrader = JsonConvert.DeserializeObject <Trader>(TestJsonObjectConsts.trader1);

            bool results = await clientWithMock.Login(user);

            AssertTradersEqual(expectedTrader, clientWithMock.thisTrader);
        }
        public async Task CantGetPackageWhenServiceIsDown()
        {
            mockBlockService.Setup(m => m.InvokeGet(HyperledgerConsts.MyPackagesUrl(TestJsonObjectConsts.trader1ID)))
            .ThrowsAsync(new HttpRequestException());
            mockBlockService.Setup(m => m.InvokeGet(HyperledgerConsts.TraderQueryURL(TestJsonObjectConsts.trader1ID)))
            .ReturnsAsync(TestJsonObjectConsts.trader1);
            mockBlockService.Setup(m => m.InvokePostAuthentication(FlaskConsts.LoginUrl, JsonConvert.SerializeObject(user)))
            .ReturnsAsync(TestJsonObjectConsts.trader1AuthenticationMessage);

            await clientWithMock.Login(user);

            List <Package> results = await clientWithMock.GetMyPackages();

            Assert.IsNull(results);
        }
        public async Task GetMyPackagesMethodWillInvokeMyPackagesUrl()
        {
            mockBlockService.Setup(m => m.InvokeGet(HyperledgerConsts.MyPackagesUrl(TestJsonObjectConsts.trader1ID)))
            .ReturnsAsync("[]");
            mockBlockService.Setup(m => m.InvokeGet(HyperledgerConsts.TraderQueryURL(TestJsonObjectConsts.trader1ID)))
            .ReturnsAsync(TestJsonObjectConsts.trader1);
            mockBlockService.Setup(m => m.InvokePostAuthentication(FlaskConsts.LoginUrl, JsonConvert.SerializeObject(user)))
            .ReturnsAsync(TestJsonObjectConsts.trader1AuthenticationMessage);

            await clientWithMock.Login(user);

            List <Package> results = await clientWithMock.GetMyPackages();

            mockBlockService.Verify(m => m.InvokeGet(HyperledgerConsts.MyPackagesUrl(TestJsonObjectConsts.trader1ID)));
        }
        public async Task If_network_is_down_cant_get_property()
        {
            mockBlockService.Setup(m => m.InvokeGet(HyperledgerConsts.TraderQueryURL(TestJsonObjectConsts.trader1ID)))
            .ReturnsAsync(TestJsonObjectConsts.trader1);
            mockBlockService.Setup(m => m.InvokePostAuthentication(FlaskConsts.LoginUrl, JsonConvert.SerializeObject(user)))
            .ReturnsAsync(TestJsonObjectConsts.trader1AuthenticationMessage);
            mockBlockService.Setup(m => m.InvokeGet(HyperledgerConsts.MyAssetsUrl(TestJsonObjectConsts.trader1ID)))
            .ThrowsAsync(new HttpRequestException());

            await clientWithMock.Login(user);

            List <Property> results = await clientWithMock.GetMyProperties();

            Assert.IsNull(results);
        }
        public async Task Get_My_Assets_Will_InvokeGet_From_BlockchainService()
        {
            mockBlockService.Setup(m => m.InvokeGet(HyperledgerConsts.TraderQueryURL(TestJsonObjectConsts.trader1ID)))
            .ReturnsAsync(TestJsonObjectConsts.trader1);
            mockBlockService.Setup(m => m.InvokePostAuthentication(FlaskConsts.LoginUrl, JsonConvert.SerializeObject(user)))
            .ReturnsAsync(TestJsonObjectConsts.trader1AuthenticationMessage);
            mockBlockService.Setup(m => m.InvokeGet(HyperledgerConsts.MyAssetsUrl(TestJsonObjectConsts.trader1ID)))
            .ReturnsAsync("[]");

            await clientWithMock.Login(user);

            List <Property> results = await clientWithMock.GetMyProperties();

            mockBlockService.Verify(m => m.InvokeGet(HyperledgerConsts.TraderQueryURL(TestJsonObjectConsts.trader1ID)));
        }