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); }
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); }
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); }
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); }
public Task <TransactionReceipt> SetEshopRequestAndWaitForReceiptAsync(Eshop eShop, CancellationTokenSource cancellationToken = null) { var setEshopFunction = new SetEshopFunction(); setEshopFunction.EShop = eShop; return(ContractHandler.SendRequestAndWaitForReceiptAsync(setEshopFunction, cancellationToken)); }
public Task <string> SetEshopRequestAsync(Eshop eShop) { var setEshopFunction = new SetEshopFunction(); setEshopFunction.EShop = eShop; return(ContractHandler.SendRequestAsync(setEshopFunction)); }
public void EshopCheckingLoginReturnsFalse() { //Assign var eshop = new Eshop(); //Act var result = eshop.TryLogin("pass", "user"); //Assert Assert.AreEqual(false, result); }
public void EshopCheckingLoginReturnsTrue() { //Assign var eshop = new Eshop(); //Act var result = eshop.TryLogin("user", "upass"); //Assert Assert.AreEqual(true, result); }
public void EshopCheckingRegistrationReturnsFalse() { //Assign var eshop = new Eshop(); //Act var result = eshop.Register("user", "pass"); //Assert Assert.AreEqual(false, result); }
public void EshopCheckingRegistrationReturnsTrue() { //Assign var eshop = new Eshop(); //Act var result = eshop.Register("login", "pass"); //Assert Assert.AreEqual(true, result); }
static void Main(string[] args) { Eshop eshop = new Eshop(); eshop.MakeAndDisplayTShirt(); eshop.ChooseAndDispayPaymentMethod(); eshop.TryToPayAndDisplayTheResult(); Console.ReadKey(); }
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); }
partial void InsertCompany(Eshop.Core.DataAccessModel.Company instance);
partial void InsertProduct(Eshop.Core.DataAccessModel.Product instance);
partial void DeleteProduct(Eshop.Core.DataAccessModel.Product instance);
partial void DeleteCompCat(Eshop.Core.DataAccessModel.CompCat instance);
partial void InsertCompCat(Eshop.Core.DataAccessModel.CompCat instance);
partial void DeleteCategory(Eshop.Core.DataAccessModel.Category instance);
partial void InsertCategory(Eshop.Core.DataAccessModel.Category instance);
partial void DeleteCompany(Eshop.Core.DataAccessModel.Company instance);