Esempio n. 1
0
        public async void CheckUserDisconnected()
        {
            var repo      = new FakeRepo(_context);
            var fakeUser  = repo.FakeSingleUser();
            var fakeQueue = repo.FakeSingleQueue();

            var connection = MakeHubConnection();

            await connection.StartAsync();

            await connection.InvokeAsync("RegisterDoctor", fakeUser.Id, fakeUser.RoomNo);

            await connection.StopAsync();

            await Task.Delay(5000);

            fakeQueue = _context.Queue.FindByCondition(q => q.Id == fakeQueue.Id).SingleOrDefault();

            bool result         = false;
            var  connectedUsers = _hubUser.GetConnectedUserById(fakeUser.Id);

            if (connectedUsers == null)
            {
                result = true;
            }

            Assert.True(!fakeQueue.IsActive);
            Assert.True(result);
        }
Esempio n. 2
0
        public void Setup()
        {
            _accounting = new TDD_AccountSystem_½m²ß.Accounting();
            var fakeRepo = new FakeRepo();

            _accounting.Repo = fakeRepo;
        }
Esempio n. 3
0
        public async Task CheckRegisterNewDoctor()
        {
            //System.Diagnostics.Debugger.Launch();
            var repo     = new FakeRepo(_context);
            var fakeUser = repo.FakeSingleUser();

            var fakeQueue     = repo.FakeSingleQueue();
            var expectedQueue = _mapper.Map <WebApp.Models.Queue>(fakeQueue);

            var connection = MakeHubConnection();

            MakeDoctorFullNameReceive(connection);
            MakeQueueNoReceive(connection);
            MakeQueueAdditionalMessageReceive(connection);

            await connection.StartAsync();

            await connection.InvokeAsync("RegisterDoctor", fakeUser.Id, fakeUser.RoomNo);

            fakeQueue = _context.Queue.FindByCondition(q => q.UserId == fakeUser.Id).SingleOrDefault();

            string expected = QueueHelper.GetDoctorFullName(fakeUser);

            Assert.True(fakeQueue.IsActive);

            Assert.Equal(expected, HubResponse.ReceiveDoctorFullName);
            Assert.Equal(fakeUser.Id, HubResponse.ReceiveUserId);

            Assert.Equal(expectedQueue.QueueNoMessage, HubResponse.ReceiveQueueNo);
            Assert.Equal(expectedQueue.AdditionalMessage, HubResponse.ReceiveAdditionalMessage);

            await connection.DisposeAsync();
        }
Esempio n. 4
0
 public ScheduleVM()
 {
     IsShowFrame = false;
     SelectedRow = 0;
     EndRow      = 1;
     StartTime   = new TimeSpan();
     TaskItems   = FakeRepo.GetTaskForCurentDate(CurentDateDay);
 }
        public CheckedLists()
        {
            InitializeComponent();
            IList <Product> all = FakeRepo.GetAllProducts();

            lstProductsRB.ItemsSource    = all;
            lstProductsCheck.ItemsSource = all;
        }
 public IndexModel()
 {
     // here we called singelton pattern instance ( we need always current updated instance which is only possible through this design pattern)
     // Page to page communication we need always updated instance of Fakerepo which possible by through this means.
     repo = FakeRepo.Instance;
     //when we use dependency Injection we dont need to create an FakeRepo object instance in a constructor
     // repo = new FakeRepo();
     // Here are we call the GetAllStudents method to retrieve current Dictionary Object List
     Students = repo.GetAllStudents();
 }
Esempio n. 7
0
        public void DayChanged(object sender, EventArgs e)
        {
            var calendar = sender as CalendarVM;

            Debug.WriteLine("-----sel date = " + calendar.SelDate);
            CurentDateDay = calendar.SelDate;

            TaskItems = FakeRepo.GetTaskForCurentDate(CurentDateDay);
            DoListItemsChanged();
        }
        private void Save()
        {
            var item = new TaskItem();

            item.DateTimeRenge = new DateTimeRenge(CurentDateTime.Date.Add(StartTime), CurentDateTime.Date.Add(EndTime));
            item.Text          = TextMessage;
            var result = FakeRepo.InsertItem(item);

            Application.Current.MainPage.DisplayAlert("Result", result.ToString(), "OK");

            DoCloseWindow();
        }
Esempio n. 9
0
        public void ReturnFalse_AfterInvokingAction()
        {
            // TODO: Add the shim in here, because the test would pass regardless
            const int   intervalInMinutes = 1;
            IRepository repository        = new FakeRepo();
            var         currencyUpdate    = new CurrencyUpdate(intervalInMinutes, new CurrencyGenerator(new List <IChatClient>(), new ChatUserCollection(repository)));

            bool result = false;

            currencyUpdate.Invoke();
            result = currencyUpdate.IsTimeToRun();
            Assert.False(result);
        }
Esempio n. 10
0
        public void AddWShopTest()
        {
            var fakeRepo = new FakeRepo();
            var wshop    = new WShop()
            {
                WShopName = "Name", Owner = new WCitizen()
                {
                    Name = "John", UserName = "******"
                }
            };

            fakeRepo.AddWShop(wshop);

            var retrievedWShop = fakeRepo.wshops.ToList()[0];

            Assert.Equal(0, wshop.WShopName.CompareTo(retrievedWShop.WShopName));
        }
Esempio n. 11
0
        public void GetByOwnerTest()
        {
            var fakeRepo = new FakeRepo();
            var wshop    = new WShop()
            {
                WShopName = "Name", Owner = new WCitizen()
                {
                    Name = "John", UserName = "******"
                }
            };

            fakeRepo.AddWShop(wshop);

            var retrievedWShop = fakeRepo.GetWShopByOwner("John");

            Assert.Equal(0, wshop.WShopName.CompareTo(retrievedWShop.WShopName));
        }
Esempio n. 12
0
        public void CanChangeName()
        {
            User user = new User()
            {
                LoginName = "me"
            };
            FakeRepo repo = new FakeRepo();

            repo.Add(user);
            TestController target  = new TestController(repo);
            string         oldname = user.LoginName;
            string         newName = "이얍";

            target.ChangeLoginName(oldname, newName);

            Assert.AreEqual(newName, user.LoginName);
            Assert.IsTrue(repo.DidChangeSubmit);
        }
Esempio n. 13
0
        public async Task RegisterMultipleDoctors(int reps)
        {
            string roomNo    = "12";
            var    repo      = new FakeRepo(_context);
            var    fakeUsers = repo.FakeMultipleUsers(reps, roomNo);

            var fakeQueues = repo.FakeMultipleQueues(fakeUsers);
            List <WebApp.Models.Queue> expectedQueues = _mapper.Map <List <WebApp.Models.Queue> >(fakeQueues);

            var connection = MakeHubConnection();

            MakeDoctorFullNameReceive(connection);
            MakeQueueNoReceive(connection);
            MakeQueueAdditionalMessageReceive(connection);
            MakeNotifyQueueOccupied(connection);

            await connection.StartAsync();

            int occupiedMsgCount   = 0;
            int queueMsgMatchCount = 0;

            for (int i = 0; i < fakeUsers.Count; i++)
            {
                await connection.InvokeAsync("RegisterDoctor", fakeUsers[i].Id, fakeUsers[i].RoomNo);

                if (!String.IsNullOrEmpty(HubResponse.ReceiveQueueOccupied))
                {
                    occupiedMsgCount++;
                    HubResponse.ReceiveQueueOccupied = String.Empty;
                }
                if (HubResponse.ReceiveQueueNo.Equals(expectedQueues[i].QueueNoMessage))
                {
                    queueMsgMatchCount++;
                    HubResponse.ReceiveQueueNo = String.Empty;
                }
            }

            Assert.Equal(reps - 1, occupiedMsgCount);
            Assert.Equal(reps - 1, _hubUser.GetWaitingUsersCount(roomNo));
            Assert.Equal(1, _hubUser.GetConnectedUsersCount(roomNo));
        }
Esempio n. 14
0
        public async void CheckQueueOccupied()
        {
            var repo          = new FakeRepo(_context);
            var fakeUser      = repo.FakeSingleUser();
            var fakeQueue     = repo.FakeSingleQueue();
            var expectedQueue = _mapper.Map <WebApp.Models.Queue>(fakeQueue);

            //put user in empty groud -> will go to ConnectedUsers list
            _hubUser.AddUser(new FakeHubUser("234", "12345", "12").Build());

            var connection = MakeHubConnection();

            MakeNotifyQueueOccupied(connection);

            await connection.StartAsync();

            await connection.InvokeAsync("RegisterDoctor", fakeUser.Id, fakeUser.RoomNo);

            var expectedMessage = StaticDetails.QueueOccupiedMessage;

            Assert.Equal(expectedMessage, HubResponse.ReceiveQueueOccupied);
        }
Esempio n. 15
0
        public Application()
        {
            InitializeComponent();

            if (ScreenWidth == 0 || ScreenHeight == 0)
            {
                ScreenWidth  = 600;
                ScreenHeight = 800;
            }

            FakeRepo.InsertItem(new TaskItem()
            {
                DateTimeRenge = new DateTimeRenge(DateTime.Now, DateTime.Now.Add(new TimeSpan(2, 0, 0))),
                Text          = "some text ..."
            });
            FakeRepo.InsertItem(new TaskItem()
            {
                DateTimeRenge = new DateTimeRenge(DateTime.Now.AddDays(1), DateTime.Now.AddDays(1).Add(new TimeSpan(2, 0, 0))),
                Text          = "some text ..."
            });

            MainPage = new Page1();
        }
Esempio n. 16
0
 public void SetUp()
 {
     repo    = new FakeRepo();
     subject = new Cache <string, string>(repo.Get);
 }
Esempio n. 17
0
 public BehaviorsViewModel()
 {
     Products = new ObservableCollection <Product>(FakeRepo.GetAllProducts());
 }
Esempio n. 18
0
 private void cmdGetProducts_Click(object sender, RoutedEventArgs e)
 {
     products = FakeRepo.GetAllProducts();
     lstProducts.ItemsSource = products;
 }
 public F_DataTemplates()
 {
     InitializeComponent();
     lbProducts.ItemsSource = FakeRepo.GetAllProducts();
 }
Esempio n. 20
0
        public MainViewModel()
        {
            MainWindows = new MainWindow();



            Food = new Food
            {
                Name      = "Foods",
                Weight    = 0,
                Price     = 0,
                ImagePath = "../Images/DefaultImage.png",
                Quantity  = 0,
                Sum       = 0,
            };



            FoodRepository = new FakeRepo();
            Foods          = new ObservableCollection <Food>(FoodRepository.GetAll());


            EditCommand = new RelayCommand((e) =>
            {
                var editWindow            = new EditWindow();
                EditViewModel             = new EditViewModel();
                EditViewModel.EditFood    = Food;
                EditViewModel.EditWindows = editWindow; //for close EditView
                editWindow.DataContext    = EditViewModel;



                editWindow.ShowDialog();
            });


            HistoryViewModels = new HistoryViewModel();

            ResetCommand = new RelayCommand((e) =>
            {
                Food = new Food
                {
                    Name      = "Foods",
                    Weight    = 0,
                    Price     = 0,
                    ImagePath = "../Images/DefaultImage.png",
                    Quantity  = 0,
                    Sum       = 0,
                };
            });



            BuyCommand = new RelayCommand((e) =>
            {
                Name = Food.Name; Price = Food.Price; Weight = Food.Weight; ImagePath = Food.ImagePath; Quantity = Food.Quantity; Sum = Food.Sum;



                var historyWindow = new HistoryWindow();

                if (HistoryViewModels.MyHistoryFood == null)
                {
                    HistoryViewModels = new HistoryViewModel(Name, Price, Weight, ImagePath, Quantity, Sum);
                    HistoryViewModels.MyHistoryFood = new ObservableCollection <Food>();
                    for (int i = 0; i < Quantity; i++)
                    {
                        HistoryViewModels.MyHistoryFood.Add(Food);
                        HistoryViewModels.MyHistoryFood.RemoveAt(0);
                    }
                }

                if (HistoryViewModels.MyHistoryFood != null)
                {
                    for (int i = 0; i < Quantity; i++)
                    {
                        HistoryViewModels.MyHistoryFood.Add(Food);
                    }
                }


                HistoryViewModels.HistoryWindows = historyWindow;

                var MainWindows = new MainWindow();

                HistoryViewModel historyViewModel = new HistoryViewModel();


                Sum += Food.Quantity * Food.Price;

                Food.Sum = Sum;



                MessageBox.Show(Sum.ToString());

                historyWindow.DataContext = HistoryViewModels;

                historyWindow.ShowDialog();
            });
        }
Esempio n. 21
0
 public EditPageModel()
 {
     EditStudent = new Student();
     repo        = FakeRepo.Instance;
 }
 public HomeController()
 {
     repo = new FakeRepo();
 }
 public BasicGridView()
 {
     InitializeComponent();
     lstProducts.ItemsSource = FakeRepo.GetAllProducts();
     // new StoreDbWithDataSet().GetProducts().DefaultView;
 }
Esempio n. 24
0
 public TreeView()
 {
     InitializeComponent();
     treeOrders.ItemsSource = FakeRepo.GetAllCategories();
 }
Esempio n. 25
0
 public void RefreshItems(object sender, EventArgs e)
 {
     TaskItems.Clear();
     TaskItems = FakeRepo.GetTaskForCurentDate(CurentDateDay);
     DoListItemsChanged();
 }