public void DBStoreTest_Update()
        {
            DBStore db    = new DBStore();
            var     store = db.Get(2);

            var addressOld    = store.Address;
            var addressNew    = "New Address 1";
            var districtIdOld = store.District.Id;
            var districtIdNew = 3;

            store.Address     = addressNew;
            store.District.Id = districtIdNew;

            db.Update(store);
            store = null;

            store = db.Get(2);
            Assert.AreEqual(addressNew, store.Address);
            Assert.AreEqual(districtIdNew, store.District.Id);

            //cleanup
            store.Address     = addressOld;
            store.District.Id = districtIdOld;
            db.Update(store);
        }
        async Task <int> CreateStores()
        {
            string[] names = { "XTZ Bike Shop", "CBIKE Cycling Store", "Be the bike", "Bikes Store" };

            int id = 1;

            foreach (var name in names)
            {
                var store = new DBStore()
                {
                    Id           = id.ToString(),
                    Name         = name,
                    Description  = "Store service description",
                    Rating       = Randomize.Next(0, 5),
                    Address      = "15 Ski App Way, Redmond Heights Way",
                    City         = "Washington",
                    Country      = "USA",
                    Email        = "*****@*****.**",
                    Location     = new Point(40.721847, -74.007326),
                    Phone        = "11",
                    State        = "Washington",
                    CreationDate = DateTime.UtcNow
                };

                await CreateStore(store);

                id++;
            }

            return(id);
        }
Пример #3
0
        public void addStoreTest()
        {
            Store s1 = new Store("store", "store");
            int   ID = DBStore.getInstance().addStore(s1);

            Assert.AreNotEqual(DBStore.getInstance().getStore(ID), null);
        }
Пример #4
0
        public void closeStoreTest()
        {
            int ID = DBStore.getInstance().addStore(s);

            DBStore.getInstance().closeStore(s);
            Assert.IsFalse(s.isActive());
        }
Пример #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here

            SetContentView(Resource.Layout.FinishQuizLayout);

            DBStore db = new DBStore();

            btnTryAgain      = FindViewById <Button>(Resource.Id.btnTryAgain);
            txtTotalQuestion = FindViewById <TextView>(Resource.Id.txtTotalQuestion);
            txtTotalScore    = FindViewById <TextView>(Resource.Id.txtTotalScore);

            btnTryAgain.Click += delegate
            {
                Intent intent = new Intent(this, typeof(MainActivity));
                StartActivity(intent);
                Finish();
            };

            Bundle bundle = Intent.Extras;

            if (bundle != null)
            {
                int score         = bundle.GetInt("Score");
                int totalQuestion = bundle.GetInt("Total");
                int correctAnswer = bundle.GetInt("Correct");

                txtTotalScore.Text    = $"Score: {score}";
                txtTotalQuestion.Text = $"You got {correctAnswer}/{totalQuestion}";

                db.InsertScore(score);
            }
        }
Пример #6
0
 public void TestInitialize()
 {
     storeService = StoreService.getInstance();
     userService  = UserService.getInstance();
     DBStore.getInstance().init();
     DBSubscribedUser.getInstance().cleanDB();
 }
Пример #7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.QuizLayout);
            DBStore dBStore = new DBStore();

            Category = Intent.GetStringExtra("Category");
            Enum.TryParse(Category, out QuizCategory category);
            //Pull Data from database
            List <Quiz> CompleteQuizlist = dBStore.GetQuizList();                     //Extract questions from database

            ChosenList = CurrentQuestion.GetQuizCategory(CompleteQuizlist, category); //Pass into second list with category selected
            ChosenList = CurrentQuestion.PullXRandomQuestions(5, ChosenList);         //
            Question   = ChosenList[0];
            #region LayoutWireUP
            txtQuestion      = FindViewById <TextView>(Resource.Id.txtQuestion);
            rbAnswer1        = FindViewById <RadioButton>(Resource.Id.radioAnswer1);
            rbAnswer2        = FindViewById <RadioButton>(Resource.Id.radioAnswer2);
            rbAnswer3        = FindViewById <RadioButton>(Resource.Id.radioAnswer3);
            btnSubmitAnswer  = FindViewById <Button>(Resource.Id.btnSubmitAnswer);
            radioAnswerGroup = FindViewById <RadioGroup>(Resource.Id.radioAnswerGroup);
            wrongAnswerSound = MediaPlayer.Create(this, Resource.Raw.WrongAnswer);
            rightAnswerSound = MediaPlayer.Create(this, Resource.Raw.RightAnswer);
            finishQuizSound  = MediaPlayer.Create(this, Resource.Raw.FinishQuiz);
            lblQuestionCount = FindViewById <TextView>(Resource.Id.lblQuestionCount);
            lblScore         = FindViewById <TextView>(Resource.Id.lblScore);
            #endregion
            txtQuestion.Text = Question.Question;
            RandomiseButtons(Question);
            btnSubmitAnswer.Click += BtnSubmitAnswer_Click;
        }
Пример #8
0
 public void TestInitialize()
 {
     DBStore.getInstance().DBinit();
     s  = new Store("store", "store");
     su = new SubscribedUser("u", "u", new ShoppingBasket());
     sr = new StoreOwner(null, su, s);
 }
Пример #9
0
        public void addToCartTest1()
        {
            Product p1 = new Product("p1", "ff", 56, 2, 10, DBStore.getInstance().getStore(store1));

            basket.addToCart(p1, 5);
            Assert.AreEqual(basket.getShoppingCarts().Keys.Count, 1);
        }
Пример #10
0
        private bool Create()
        {
            this.guid = Guid.NewGuid();

            int rowsAffected = DBStore.Add(
                this.guid,
                this.siteGuid,
                this.moduleID,
                this.name,
                this.description,
                this.ownerName,
                this.ownerEmail,
                this.salesEmail,
                this.supportEmail,
                this.emailFrom,
                this.orderBCCEmail,
                this.phone,
                this.fax,
                this.address,
                this.city,
                this.zoneGuid,
                this.postalCode,
                this.countryGuid,
                this.isClosed,
                this.closedMessage,
                this.created,
                this.createdBy);



            return(rowsAffected > 0);
        }
Пример #11
0
        public void addManager(int storeid, string username,
                               bool editProduct, bool editDiscount, bool editPolicy, Session session)
        {
            SubscribedUser toAdd = DBSubscribedUser.getInstance().getSubscribedUser(username);

            if (toAdd == null)
            {
                throw new DoesntExistException("no such username");
            }
            Store store = DBStore.getInstance().getStore(storeid);

            if (store == null)
            {
                throw new DoesntExistException("no such store");
            }
            StoreRole sr = store.getStoreRole(session.getSubscribedUser());

            if (sr.getStore() != store)
            {
                throw new RoleException("this user can't appoint to this store");
            }
            Permissions permissions = new Permissions(editProduct, editDiscount, editPolicy);

            sr.addManager(toAdd, permissions);
        }
Пример #12
0
        public void removeStoreTest()
        {
            int ID = DBStore.getInstance().addStore(s);

            Assert.AreEqual(DBStore.getInstance().removeStore(s), "");
            Assert.AreEqual(DBStore.getInstance().getStore(ID), null);
            Assert.AreNotEqual(DBStore.getInstance().removeStore(s), "");
        }
Пример #13
0
 public StoreListViewModel(DBStore store)
 {
     if (store != null)
     {
         StoreId = store.Id;
         Name    = store.Name;
     }
 }
Пример #14
0
        public void HandleDeleteWorkingHours(object sender, EventArgs e)
        {
            CalendarEvent cevent = (CalendarEvent)sender;

            DBStore store = new DBStore();

            store.DeleteWorkingHours(cevent.Event.InsertId);
        }
Пример #15
0
        public static bool DeleteBySite(int siteId)
        {
            SiteSettings site = new SiteSettings(siteId);

            Discount.DeleteBySite(site.SiteGuid);

            return(DBStore.DeleteBySite(siteId));
        }
Пример #16
0
        public void GetAllTest()
        {
            DBStore dB  = new DBStore(this.dBConnect);
            var     ppl = dB.GetAll();

            Assert.IsNotNull(ppl, "Null object returned");
            Assert.IsTrue(ppl.Count() > 0, "There are no stores");
        }
Пример #17
0
 public void Initialize()
 {
     userService  = UserService.getInstance();
     storeService = StoreService.getInstance();
     session      = userService.startSession();
     DBStore.getInstance().init();
     DBSubscribedUser.getInstance().cleanDB();
 }
Пример #18
0
 public void TestInitialize()
 {
     MarketSystem.initTestWitOutRead();
     s = new Store("store", "store");
     DBStore.getInstance().addStore(s);
     su = new SubscribedUser("u", "u", new ShoppingBasket());
     sr = new StoreOwner(null, su, s);
 }
Пример #19
0
        public void AddIllegalTest()
        {
            DBStore dB = new DBStore(this.dBConnect);

            dB.Create(new Store()
            {
                Name = null
            });
        }
Пример #20
0
 public void initial()
 {
     MarketSystem.initTestWitOutRead();
     //DBProduct.getInstance().initTests();
     //DBProduct.getInstance().initTests();
     //DBStore.getInstance().initTests();
     store = new Store("store1", "games store");
     DBStore.getInstance().addStore(store);
     cart = new ShoppingCart(store.getStoreID());
 }
Пример #21
0
        public void UpdateIllegalNegativeTest()
        {
            DBStore dB = new DBStore(this.dBConnect);
            var     sp = new Store()
            {
                ID = -4
            };

            dB.Update(sp);
        }
Пример #22
0
        public void Remove(AStore genericType)
        {
            DBStore existingStore = context.DBStores.ToList().Find(store => store.Name.Equals(genericType.Name));

            if (existingStore is not null)
            {
                context.Remove(existingStore);
                context.SaveChanges();
            }
        }
        public void DBStoreTest_Persist_fail_District()
        {
            DBStore db    = new DBStore();
            Store   store = new Store()
            {
                Name = "asdasd", Address = "x"
            };

            db.Persist(store);
        }
        public void DBStoreTest_Update_fail_District()
        {
            DBStore db    = new DBStore();
            Store   store = new Store()
            {
                Id = 2
            };

            db.Update(store);
        }
        public void DBStoreTest_Update_fail_ID()
        {
            DBStore db    = new DBStore();
            Store   store = new Store()
            {
                Id = -1
            };

            db.Update(store);
        }
Пример #26
0
        public void Remove(int id)
        {
            DBStore existingStore = context.DBStores.FirstOrDefault(store => store.ID == id);

            if (existingStore is not null)
            {
                context.Remove(existingStore);
                context.SaveChanges();
            }
        }
        public void DBStoreTest_getAll()
        {
            DBStore db = new DBStore();

            var stores = db.GetAll();

            Assert.AreNotEqual(0, stores.ToList().Count);
            Assert.AreEqual("Shop 1", stores.ToList()[0].Name);
            Assert.IsNotNull(stores.ToList()[2].District);
        }
Пример #28
0
        public void closeStore(int storeid, Session session)
        {
            Store store = DBStore.getInstance().getStore(storeid);

            if (store == null)
            {
                throw new DoesntExistException("no such store");
            }
            session.closeStore(store);
        }
Пример #29
0
        public int addProduct(string productName, string productCategory, int price, int rank, int quantityLeft, int storeID, Session session)
        {
            DBStore   storeDB = DBStore.getInstance();
            Store     store   = storeDB.getStore(storeID);
            StoreRole sr      = store.getStoreRole(session.getSubscribedUser());
            Product   product = new Product(productName, productCategory, price, rank, quantityLeft, store);

            sr.addProduct(product);
            return(product.getProductID());
        }
Пример #30
0
        public TotalPricePolicy(int totalPrice)
        {
            if (totalPrice < 0)
            {
                throw new ILLArgumentException("total price can not be a negative number.");
            }

            this.totalPrice = totalPrice;

            this.policyID = DBStore.getInstance().getNextPolicyID();
        }