// 'Verify the usage of EnumExtension'
        public void VeryfyCorrectEnumExtension()
        {
            //This is the comparison class
            CompareLogic compareLogic = new CompareLogic();

            MembershipType mblack  = MembershipType.BLACK;
            MembershipType mbronze = MembershipType.BRONZE;
            MembershipType mgold   = MembershipType.GOLD;
            MembershipType msilver = MembershipType.SILVER;

            String sblack  = MyEnumExtensions.ToEnumMemberAttrValue(mblack);
            String sbronze = MyEnumExtensions.ToEnumMemberAttrValue(mbronze);
            String sgold   = MyEnumExtensions.ToEnumMemberAttrValue(mgold);
            String ssilver = MyEnumExtensions.ToEnumMemberAttrValue(msilver);

            Assert.AreEqual(sblack, "black");
            Assert.AreEqual(sbronze, "bronze");
            Assert.AreEqual(sgold, "gold");
            Assert.AreEqual(ssilver, "silver");

            BroadcastingMode modeAsync = BroadcastingMode.ASYNC;
            BroadcastingMode modeBlock = BroadcastingMode.BLOCK;
            BroadcastingMode modeSync  = BroadcastingMode.SYNC;

            Assert.AreEqual(MyEnumExtensions.ToEnumMemberAttrValue(modeAsync), "async");
            Assert.AreEqual(MyEnumExtensions.ToEnumMemberAttrValue(modeBlock), "block");
            Assert.AreEqual(MyEnumExtensions.ToEnumMemberAttrValue(modeSync), "sync");
        }
        // '"fromWallet()" returns a well-formed "BuyMembership" object.'
        public async Task WellFormedBuyMembershipFromWalletAsync()
        {
            //This is the comparison class
            CompareLogic  compareLogic   = new CompareLogic();
            String        lcdUrl         = "http://localhost:1317";
            string        didcom         = "1fvwfjx2yealxyw5hktqnvm5ynljlc8jqkkd8kl";
            NetworkInfo   networkInfo    = new NetworkInfo(bech32Hrp: "did:com:" + didcom, lcdUrl: "");
            String        mnemonicString = "gorilla soldier device force cupboard transfer lake series cement another bachelor fatigue royal lens juice game sentence right invite trade perfect town heavy what";
            List <String> mnemonic       = new List <String>(mnemonicString.Split(" ", StringSplitOptions.RemoveEmptyEntries));
            Wallet        wallet         = Wallet.derive(mnemonic, networkInfo);

            MembershipType membershipType = MembershipType.GREEN;

            BuyMembership expectedBuyMembership = new BuyMembership(membershipType: MyEnumExtensions.ToEnumMemberAttrValue(membershipType), buyerDid: wallet.bech32Address, tsp: "");

            BuyMembership buyMembership = BuyMembershipHelper.fromWallet(wallet, MembershipType.GREEN, tsp: "");

            MsgBuyMembership MsgMember     = new MsgBuyMembership(buyMembership);
            String           localTestUrl1 = $"{lcdUrl}/commercio/MsgBuyMembership";

            var _server = new MockHttpServer();

            //////  I need this in order to get the correct data out of the mock server
            ////Dictionary<string, object> nodeResponse1 = JsonConvert.DeserializeObject<Dictionary<String, Object>>(TestResources.TestResources.accountResponse);
            ////// Dictionary<String, Object> nodeResponse2 = JsonConvert.DeserializeObject<Dictionary<String, Object>>(TestResources.TestResources.tumblerIdentityJson);
            ////// Initialize Server Response
            _server
            .WithService(localTestUrl1)
            .Api("", "GET", MsgMember);

            // Link the client to the retrieval class Network
            HttpClient client = new HttpClient();

            Network.client = client;
            // Get the server response
            HttpResponseMessage response = await client.GetAsync(localTestUrl1);

            if (response.StatusCode != System.Net.HttpStatusCode.OK)
            {
                System.ArgumentException argEx = new System.ArgumentException($"Expected status code OK (200) but got ${response.StatusCode} - ${response.ReasonPhrase}");
                throw argEx;
            }

            // Parse the data
            String jsonResponse = await response.Content.ReadAsStringAsync();



            Assert.AreEqual(compareLogic.Compare(buyMembership.toJson(), expectedBuyMembership.toJson()).AreEqual, true);
        }
Example #3
0
        // '"fromWallet()" returns a well-formed "BuyMembership" object.'
        public void WellFormedBuyMembershipFromWallet()
        {
            //This is the comparison class
            CompareLogic compareLogic = new CompareLogic();

            NetworkInfo   networkInfo    = new NetworkInfo(bech32Hrp: "did:com:", lcdUrl: "");
            String        mnemonicString = "dash ordinary anxiety zone slot rail flavor tortoise guilt divert pet sound ostrich increase resist short ship lift town ice split payment round apology";
            List <String> mnemonic       = new List <String>(mnemonicString.Split(" ", StringSplitOptions.RemoveEmptyEntries));
            Wallet        wallet         = Wallet.derive(mnemonic, networkInfo);

            MembershipType membershipType = MembershipType.BLACK;

            BuyMembership expectedBuyMembership = new BuyMembership(membershipType: MyEnumExtensions.ToEnumMemberAttrValue(membershipType), buyerDid: wallet.bech32Address);

            BuyMembership buyMembership = BuyMembershipHelper.fromWallet(wallet, MembershipType.BLACK);

            Assert.AreEqual(compareLogic.Compare(buyMembership.toJson(), expectedBuyMembership.toJson()).AreEqual, true);
        }