コード例 #1
0
        public void OpenTwoStores()
        {
            int  res1  = 0;
            int  res2  = 0;
            Task user1 = Task.Factory.StartNew(() => { res1 = sm.createStore(buyer, "s1").Item1; });
            Task user2 = Task.Factory.StartNew(() => { res2 = sm.createStore("yosi", "s2").Item1; });

            Task.WaitAll(user1, user2);
            Assert.IsTrue(res1 != res2, "open store concurrency failed");
        }
コード例 #2
0
        public static Store initValidStore()
        {
            StoreManagment sm          = StoreManagment.Instance;
            UserManager    userManager = UserManager.Instance;

            userManager.Register("shimon", "123");
            userManager.Login("shimon", "123", false);
            sm.createStore("shimon", "Store");
            userManager.Register("yosi", "123");
            userManager.Login("yosi", "123");
            userManager.Register("shmuel", "123");
            userManager.Login("shmuel", "123");
            AppoitmentManager appmgr = AppoitmentManager.Instance;

            appmgr.AppointStoreManager("shimon", "shmuel", 100);
            appmgr.AppointStoreManager("shimon", "yosi", 100);
            userManager.GetAtiveUser("shmuel").setPermmisions(100, new int[] { 0, 0, 1, 0, 0 });
            userManager.GetAtiveUser("yosi").setPermmisions(100, new int[] { 1, 1, 0, 0, 0 });

            Store validStore = sm.getStore(100);

            validStore.Inventory = InventoryTest.getInventory(InventoryTest.getValidInventroyProdList());

            return(validStore);
        }
コード例 #3
0
 public void RemoveOwnerLoop()
 {
     UM.Register("user1", "Test1");
     UM.Register("user2", "Test1");
     UM.Register("user3", "Test1");
     UM.Register("user4", "Test1");
     UM.Register("user5", "Test1");
     UM.Register("user6", "Test1");
     UM.Register("user7", "Test1");
     UM.Register("user8", "Test1");
     UM.Register("user9", "Test1");
     UM.Login("user1", "Test1");
     SM.createStore("user1", "Store7");
     //User1 Store Owner
     //User1 Appoint User2 -> User2 Appoint user3 -> user3 appoint user4
     //user2 appoint user5 manager -> user4 appoint user6 manager
     //user1 appoint user7 owner
     //user1 appoint user8 managers
     //Should stay user1 user7 user8
     Assert.IsTrue(AP.AppointStoreOwner("user1", "user2", 101).Item1);
     UM.Login("user2", "Test1");
     Assert.IsTrue(AP.AppointStoreOwner("user1", "user7", 101).Item1);
     Assert.IsTrue(AP.ApproveAppoitment("user2", "user7", 101, true).Item1);
     Assert.IsTrue(AP.AppointStoreManager("user1", "user8", 101).Item1);
     UM.Login("user7", "Test1");
     Assert.IsTrue(AP.AppointStoreOwner("user2", "user3", 101).Item1);
     Assert.IsTrue(AP.ApproveAppoitment("user7", "user3", 101, true).Item1);
     Assert.IsTrue(AP.ApproveAppoitment("user1", "user3", 101, true).Item1);
     UM.Login("user3", "Test1");
     Assert.IsTrue(AP.AppointStoreOwner("user3", "user4", 101).Item1);
     Assert.IsTrue(AP.ApproveAppoitment("user1", "user4", 101, true).Item1);
     Assert.IsTrue(AP.ApproveAppoitment("user7", "user4", 101, true).Item1);
     Assert.IsTrue(AP.ApproveAppoitment("user2", "user4", 101, true).Item1);
     UM.Login("user4", "Test1");
     Assert.IsTrue(AP.AppointStoreManager("user4", "user6", 101).Item1);
     Assert.IsTrue(AP.AppointStoreManager("user2", "user5", 101).Item1);
     UM.Login("user6", "Test1");
     Assert.IsTrue(AP.AppointStoreManager("user6", "user9", 101).Item1);
     AP.RemoveStoreOwner("user2", "user7", 101);
     //user 7 need to remain owner
     Assert.IsTrue(SM.getStore(101).IsStoreOwner(UM.GetUser("user7")));
     AP.RemoveStoreOwner("user1", "user2", 101);
     //Add checks if owner loop is working corrctly
     //user 7 user remains removed 2 3 4 6 9 8 stays
     Assert.IsTrue(SM.getStore(101).IsStoreOwner(UM.GetUser("user7")));
     Assert.IsFalse(SM.getStore(101).IsStoreOwner(UM.GetUser("user2")));
     Assert.IsFalse(SM.getStore(101).IsStoreOwner(UM.GetUser("user3")));
     Assert.IsFalse(SM.getStore(101).IsStoreOwner(UM.GetUser("user4")));
     Assert.IsTrue(SM.getStore(101).IsStoreManager(UM.GetUser("user8")));
     Assert.IsFalse(SM.getStore(101).IsStoreManager(UM.GetUser("user6")));
     Assert.IsFalse(SM.getStore(101).IsStoreManager(UM.GetUser("user9")));
 }
コード例 #4
0
 public void TestInitialize()
 {
     PaymentDetails  = "3333444455556666&4&11&Wolloloo&333&222222222";
     DeliveryDetails = "dani&Wollu&Wollurberg&wolocountry&12345678";
     SM = StoreManagment.Instance;
     UM = UserManager.Instance;
     AP = AppoitmentManager.Instance;
     purchaseManagement = PurchaseManagement.Instance;
     UM.Register("owner", "Test1");
     UM.Register("Appointed", "Test1");
     UM.Login("owner", "Test1");
     UM.Login("Appointed", "Test1");
     SM.createStore("owner", "Store");
     SM.getStore(100).Inventory = getInventory(getValidInventroyProdList());
 }
コード例 #5
0
 public void TestInitialize()
 {
     //SM.cleanup();
     //UM.cleanup();
     //Publisher.Instance.cleanup();
     Statistics.Instance.cleanup();
     UM = UserManager.Instance;
     SM = StoreManagment.Instance;
     UM.RegisterMaster("Admin", "Test1");
     UM.Register("user7", "Test1");
     UM.Register("user8", "Test1");
     UM.Login("Admin", "Test1");
     UM.Login("user8", "Test1");
     SM.createStore("user8", "Store1");
 }
コード例 #6
0
 public void TestInitialize()
 {
     SM = StoreManagment.Instance;
     UM = UserManager.Instance;
     AP = AppoitmentManager.Instance;
     UM.Register("owner", "Test1");
     UM.Register("Appointed", "Test1");
     UM.Login("owner", "Test1");
     UM.Login("Appointed", "Test1");
     UM.Login("", "G", true);
     SM.createStore("owner", "Store");
     UM.Register("user1", "Test1");
     UM.Register("user2", "Test1");
     UM.Register("user3", "Test1");
     Assert.IsNotNull(UM.GetAtiveUser("owner"));
     Assert.IsNotNull(UM.GetAtiveUser("Appointed"));
     Assert.IsNotNull(UM.GetAtiveUser("Guest3"));
     Assert.IsTrue(UM.GetAtiveUser("Guest3").isguest());
     Assert.IsTrue(UM.GetAtiveUser("owner").isStoreOwner(100));
     Assert.IsTrue(SM.getStore(100).IsStoreOwner(UM.GetAtiveUser("owner")));
     Assert.IsNotNull(SM.getStore(100));
 }
コード例 #7
0
 /// <req> https://github.com/chendoy/wsep_14a/wiki/Use-cases#use-case-subscription-buyer--open-store-32 </req>
 public Tuple <int, string> createStore(string userName, string storename = "Store")
 {
     return(storeManagment.createStore(userName, storename));
 }
コード例 #8
0
 public void createStoreTest()
 {
     SM.createStore("owner", "Store");
     Assert.IsTrue(SM.getStore(100).IsStoreOwner(UM.GetUser("owner")));
     Assert.IsTrue(UM.GetUser("owner").isStoreOwner(100));
 }