コード例 #1
0
        static void Main(string[] args)
        {
            List <Variation> variations = new List <Variation>()
            {
                new ColorVariation(),
                new SizeVariation(),
                new FabricVariation()
            };

            Console.WriteLine("Hello,What tshirt color u want?");
            var colorInput = Console.ReadLine().Trim().ToUpper();
            var color      = SetColor(colorInput);

            Console.WriteLine("How about Size?");
            var sizeInput = Console.ReadLine().Trim().ToUpper();
            var size      = SetSize(sizeInput);

            Console.WriteLine("Material?");
            var fabricInput = Console.ReadLine().Trim().ToUpper();
            var fabric      = SetFabric(fabricInput);

            Console.WriteLine("Choose Payment Method 1) Credit Card 2) Cash 3) Bank Transfer");
            var paymentInput = Convert.ToInt32(Console.ReadLine().Trim());
            var tShirt       = new TShirt(color, size, fabric);
            var eshop        = new Eshop();

            eshop.SetVariationStrategy(variations);
            eshop.SelectPaymentMethod(paymentInput);
            eshop.PayTShirt(tShirt);
        }
コード例 #2
0
        public async void ShouldFailToChangeEshopWhenNotCreatedBy()
        {
            // Create an eShop, then try to change it with another account, it should fail
            var eShopExpected = new Eshop()
            {
                EShopId                   = "eShopToTest" + GetRandomString(),
                EShopDescription          = "eShopDescription",
                PurchasingContractAddress = "0x94618601FE6cb8912b274E5a00453949A57f8C1e",
                IsActive                  = true,
                CreatedByAddress          = string.Empty, // filled by contract
                QuoteSignerCount          = 2,
                QuoteSigners              = new List <string>()
                {
                    "0x32A555F2328e85E489f9a5f03669DC820CE7EBe9",
                    "0x94618601FE6cb8912b274E5a00453949A57f8C1e"
                }
            };

            // Store eShop
            var txReceipt = await _contracts.Deployment.BusinessPartnerStorageService.SetEshopRequestAndWaitForReceiptAsync(eShopExpected);

            txReceipt.Status.Value.Should().Be(1);

            // Try to change eShop using preexisting bp storage service contract, but with tx executed by a different ("secondary") user
            eShopExpected.EShopDescription = "New description";
            var         bpss = new BusinessPartnerStorageService(_contracts.Web3SecondaryUser, _contracts.Deployment.BusinessPartnerStorageService.ContractHandler.ContractAddress);
            Func <Task> act  = async() => await bpss.SetEshopRequestAndWaitForReceiptAsync(eShopExpected);

            act.Should().Throw <SmartContractRevertException>().WithMessage(AUTH_EXCEPTION_ONLY_CREATEDBY);
        }
コード例 #3
0
        public async void ShouldFailToCreateEshopWhenMissingPurchasingAddress()
        {
            await Task.Delay(1);

            // Create an eShop to store, but miss out required field PurchasingContractAddress
            var eShopExpected = new Eshop()
            {
                EShopId                   = "eShopToTest" + GetRandomString(),
                EShopDescription          = "eShopDescription",
                PurchasingContractAddress = string.Empty,  // causes error
                IsActive                  = true,
                CreatedByAddress          = string.Empty,  // filled by contract
                QuoteSignerCount          = 0,             // filled by contract
                QuoteSigners              = new List <string>()
                {
                    "0x32A555F2328e85E489f9a5f03669DC820CE7EBe9",
                    "0x94618601FE6cb8912b274E5a00453949A57f8C1e"
                }
            };

            // Try to store eShop, it should fail
            Func <Task> act = async() => await _contracts.Deployment.BusinessPartnerStorageService.SetEshopRequestAndWaitForReceiptAsync(eShopExpected);

            act.Should().Throw <SmartContractRevertException>().WithMessage(BP_EXCEPTION_ESHOP_MISSING_PURCH_CONTRACT);
        }
コード例 #4
0
        public async void ShouldChangeEshopWhenCreatedBy()
        {
            // Create an eShop to store
            var eShopExpected = new Eshop()
            {
                EShopId                   = "eShopToTest" + GetRandomString(),
                EShopDescription          = "eShopDescription",
                PurchasingContractAddress = "0x94618601FE6cb8912b274E5a00453949A57f8C1e",
                IsActive                  = true,
                CreatedByAddress          = string.Empty, // filled by contract
                QuoteSignerCount          = 2,
                QuoteSigners              = new List <string>()
                {
                    "0x32A555F2328e85E489f9a5f03669DC820CE7EBe9",
                    "0x94618601FE6cb8912b274E5a00453949A57f8C1e"
                }
            };

            // Store eShop
            var txReceipt = await _contracts.Deployment.BusinessPartnerStorageService.SetEshopRequestAndWaitForReceiptAsync(eShopExpected);

            txReceipt.Status.Value.Should().Be(1);

            // Change eShop
            eShopExpected.EShopDescription = "New description";
            txReceipt = await _contracts.Deployment.BusinessPartnerStorageService.SetEshopRequestAndWaitForReceiptAsync(eShopExpected);

            txReceipt.Status.Value.Should().Be(1);

            // Retrieve eShop
            var eShopActualPostChange = (await _contracts.Deployment.BusinessPartnerStorageService.GetEshopQueryAsync(eShopExpected.EShopId)).EShop;

            // They should be the same
            CheckEveryEshopFieldMatches(eShopExpected, eShopActualPostChange, createdByAddress: _contracts.Web3.TransactionManager.Account.Address);
        }
コード例 #5
0
        public Task <TransactionReceipt> SetEshopRequestAndWaitForReceiptAsync(Eshop eShop, CancellationTokenSource cancellationToken = null)
        {
            var setEshopFunction = new SetEshopFunction();

            setEshopFunction.EShop = eShop;

            return(ContractHandler.SendRequestAndWaitForReceiptAsync(setEshopFunction, cancellationToken));
        }
コード例 #6
0
        public Task <string> SetEshopRequestAsync(Eshop eShop)
        {
            var setEshopFunction = new SetEshopFunction();

            setEshopFunction.EShop = eShop;

            return(ContractHandler.SendRequestAsync(setEshopFunction));
        }
コード例 #7
0
ファイル: UnitTests.cs プロジェクト: RKrava/ConsoleEshop
        public void EshopCheckingLoginReturnsFalse()
        {
            //Assign
            var eshop = new Eshop();
            //Act
            var result = eshop.TryLogin("pass", "user");

            //Assert
            Assert.AreEqual(false, result);
        }
コード例 #8
0
ファイル: UnitTests.cs プロジェクト: RKrava/ConsoleEshop
        public void EshopCheckingLoginReturnsTrue()
        {
            //Assign
            var eshop = new Eshop();
            //Act
            var result = eshop.TryLogin("user", "upass");

            //Assert
            Assert.AreEqual(true, result);
        }
コード例 #9
0
ファイル: UnitTests.cs プロジェクト: RKrava/ConsoleEshop
        public void EshopCheckingRegistrationReturnsFalse()
        {
            //Assign
            var eshop = new Eshop();
            //Act
            var result = eshop.Register("user", "pass");

            //Assert
            Assert.AreEqual(false, result);
        }
コード例 #10
0
ファイル: UnitTests.cs プロジェクト: RKrava/ConsoleEshop
        public void EshopCheckingRegistrationReturnsTrue()
        {
            //Assign
            var eshop = new Eshop();
            //Act
            var result = eshop.Register("login", "pass");

            //Assert
            Assert.AreEqual(true, result);
        }
コード例 #11
0
        static void Main(string[] args)
        {
            Eshop eshop = new Eshop();

            eshop.MakeAndDisplayTShirt();
            eshop.ChooseAndDispayPaymentMethod();
            eshop.TryToPayAndDisplayTheResult();

            Console.ReadKey();
        }
コード例 #12
0
        public async void ShouldStoreRetrieveAndChangeEshop()
        {
            await Task.Delay(1);

            // Create an eShop to store
            var eShopExpected = new Eshop()
            {
                EShopId                   = "eShopToTest" + GetRandomString(),
                EShopDescription          = "eShopDescription",
                PurchasingContractAddress = "0x94618601FE6cb8912b274E5a00453949A57f8C1e",
                IsActive                  = true,
                CreatedByAddress          = string.Empty, // filled by contract
                QuoteSignerCount          = 2,
                QuoteSigners              = new List <string>()
                {
                    "0x32A555F2328e85E489f9a5f03669DC820CE7EBe9",
                    "0x94618601FE6cb8912b274E5a00453949A57f8C1e"
                }
            };

            // Store eShop
            var txReceiptCreate = await _contracts.Deployment.BusinessPartnerStorageService.SetEshopRequestAndWaitForReceiptAsync(eShopExpected);

            txReceiptCreate.Status.Value.Should().Be(1);

            // Check eShop create events
            var logEshopCreateEvent = txReceiptCreate.DecodeAllEvents <EshopCreatedLogEventDTO>().FirstOrDefault();

            logEshopCreateEvent.Should().NotBeNull();
            logEshopCreateEvent.Event.EShopId.ConvertToString().Should().Be(eShopExpected.EShopId);

            // Retrieve eShop
            var eShopActual = (await _contracts.Deployment.BusinessPartnerStorageService.GetEshopQueryAsync(eShopExpected.EShopId)).EShop;

            // They should be the same
            CheckEveryEshopFieldMatches(eShopExpected, eShopActual, createdByAddress: _contracts.Web3.TransactionManager.Account.Address);

            // Change eShop
            eShopExpected.EShopDescription = "New description";
            var txReceiptChange = await _contracts.Deployment.BusinessPartnerStorageService.SetEshopRequestAndWaitForReceiptAsync(eShopExpected);

            txReceiptChange.Status.Value.Should().Be(1);

            // Check eShop change events
            var logEshopChangeEvent = txReceiptCreate.DecodeAllEvents <EshopCreatedLogEventDTO>().FirstOrDefault();

            logEshopChangeEvent.Should().NotBeNull();
            logEshopChangeEvent.Event.EShopId.ConvertToString().Should().BeEquivalentTo(eShopExpected.EShopId);

            // Retrieve the updated eShop
            var eShopActualPostChange = (await _contracts.Deployment.BusinessPartnerStorageService.GetEshopQueryAsync(eShopExpected.EShopId)).EShop;

            // Check eshop values match
            CheckEveryEshopFieldMatches(eShopExpected, eShopActualPostChange, createdByAddress: _contracts.Web3.TransactionManager.Account.Address);
        }
コード例 #13
0
ファイル: Eshop.designer.cs プロジェクト: phantrithuc/Eshop
 partial void InsertCompany(Eshop.Core.DataAccessModel.Company instance);
コード例 #14
0
ファイル: Eshop.designer.cs プロジェクト: phantrithuc/Eshop
 partial void InsertProduct(Eshop.Core.DataAccessModel.Product instance);
コード例 #15
0
ファイル: Eshop.designer.cs プロジェクト: phantrithuc/Eshop
 partial void DeleteProduct(Eshop.Core.DataAccessModel.Product instance);
コード例 #16
0
ファイル: Eshop.designer.cs プロジェクト: phantrithuc/Eshop
 partial void DeleteCompCat(Eshop.Core.DataAccessModel.CompCat instance);
コード例 #17
0
ファイル: Eshop.designer.cs プロジェクト: phantrithuc/Eshop
 partial void InsertCompCat(Eshop.Core.DataAccessModel.CompCat instance);
コード例 #18
0
ファイル: Eshop.designer.cs プロジェクト: phantrithuc/Eshop
 partial void DeleteCategory(Eshop.Core.DataAccessModel.Category instance);
コード例 #19
0
ファイル: Eshop.designer.cs プロジェクト: phantrithuc/Eshop
 partial void InsertCategory(Eshop.Core.DataAccessModel.Category instance);
コード例 #20
0
ファイル: Eshop.designer.cs プロジェクト: phantrithuc/Eshop
 partial void DeleteCompany(Eshop.Core.DataAccessModel.Company instance);