public async Task Get_given_right_guid_returns_Ok_with_items_from_service()
    {
        var calendarOptions = new CalendarOptions
        {
            Password = Guid.Parse("04a6c52fb35143799ef72f4f9a27d10c")
        };
        var options = new Mock <IOptions <CalendarOptions> >();

        options.SetupGet(o => o.Value).Returns(calendarOptions);

        var items   = new Item[0];
        var service = new Mock <ICalendarService>();

        service.Setup(s => s.GetItemsAsync()).ReturnsAsync(items);

        var groupedByTitleAndTime  = new Item[1];
        var groupedByTitleAndStaff = new Item[2];
        var converter = new Mock <ICalendarConverter>();

        converter.Setup(c => c.GroupByTitleAndTime(items)).Returns(groupedByTitleAndTime);
        converter.Setup(c => c.GroupByTitleAndStaff(groupedByTitleAndTime)).Returns(groupedByTitleAndStaff);

        var controller = new CalendarController(options.Object, service.Object, converter.Object);

        var result = await controller.Get("04a6c52fb35143799ef72f4f9a27d10c") as OkObjectResult;

        Assert.Equal(groupedByTitleAndStaff, result.Value);
    }
Exemplo n.º 2
0
    void Start()
    {
        _calendarInstance = this;
        Vector3 startPos = _item.transform.localPosition;

        _dateItems.Clear();
        _dateItems.Add(_item);

        for (int i = 1; i < _totalDateNum; i++)
        {
            GameObject item = GameObject.Instantiate(_item) as GameObject;
            item.name = "Item" + (i + 1).ToString();
            item.transform.SetParent(_item.transform.parent);
            item.transform.localScale    = Vector3.one;
            item.transform.localRotation = Quaternion.identity;
            item.transform.localPosition = new Vector3((i % 7) * 31 + startPos.x, startPos.y - (i / 7) * 25, startPos.z);

            _dateItems.Add(item);
        }

        _dateTime = DateTime.Now;

        CreateCalendar();

        _calendarPanel.SetActive(false);
    }
        public void indexNotNullTest()
        {
            CalendarController calendarController = initCalendarController(existentUserId);
            ViewResult         result             = calendarController.Index(existentProjectId) as ViewResult;

            Assert.IsNotNull(result);
        }
 public void Initialize(Patient patient, CalendarController calendarController)
 {
     this.patient            = patient;
     this.fioText.text       = $"{patient.Name} {patient.Surname}";
     this.infoText.text      = $"{patient.Phone}{Environment.NewLine}{(patient.LyingCondition ? "Малоподвижный" : "")}";
     this.calendarController = calendarController;
 }
Exemplo n.º 5
0
        public async Task TestDeleteCalendarItem()
        {
            using (var context = new BankCalendarContext(options))
            {
                // Given
                CalendarItem calendaritem1 = context.CalendarItem.First();

                // When
                CalendarController calendarController = new CalendarController(context);
                IActionResult      result             = await calendarController.DeleteCalendarItem(calendaritem1.ID) as IActionResult;

                // Then
                var okObjectResult = result as OkObjectResult;
                Assert.IsNotNull(okObjectResult);

                var model = okObjectResult.Value as CalendarItem;
                Assert.IsNotNull(model);
                Assert.AreNotEqual(0, model.ID);
                Assert.AreEqual(calendaritem1.Event, model.Event);
                Assert.AreEqual(calendaritem1.Location, model.Location);
                Assert.AreEqual(calendaritem1.Start, model.Start);
                Assert.AreEqual(calendaritem1.End, model.End);

                Assert.AreEqual(false, context.CalendarItem.Any(x => x.ID == calendaritem1.ID));
            }
        }
Exemplo n.º 6
0
    GameObject pastObj; //for effect of activate selected day


    public void Init()
    {
        _calendarInstance = this;
        Vector3 startPos = refItem.transform.localPosition;

        _dateItems.Clear();
        _dateItems.Add(refItem);

        //int itemWidth = Screen.width / 7;
        int itemWidth = 1080 / 7;

        for (int i = 1; i < _totalDateNum; i++)
        {
            GameObject item = GameObject.Instantiate(refItem) as GameObject;
            item.name = "Day_" + i.ToString("D2");
            item.transform.SetParent(refItem.transform.parent);
            item.transform.localScale    = Vector3.one;
            item.transform.localRotation = Quaternion.identity;

            //post process by scr width
            //item.transform.localPosition = new Vector3((i % 7) * 155  + startPos.x, startPos.y - (i / 7) * 80, startPos.z);
            item.transform.localPosition = new Vector3((i % 7) * itemWidth + startPos.x, startPos.y - (i / 7) * 100, startPos.z);
            item.GetComponent <RectTransform>().sizeDelta = new Vector2(itemWidth, 100f);

            _dateItems.Add(item);
        }

        _dateTime = DateTime.Now;
        CreateCalendar();
    }
Exemplo n.º 7
0
        public void Controller_Calendar_Update_Post_Id_Is_Null_Or_Empty_Should_Return_Error_Page()
        {
            // Arrange
            CalendarController controller = new CalendarController();

            SchoolCalendarModel dataNull  = new SchoolCalendarModel();
            SchoolCalendarModel dataEmpty = new SchoolCalendarModel();

            // Make data.Id = null
            dataNull.Id = null;

            // Make data.Id empty
            dataEmpty.Id = "";

            var context = CreateMoqSetupForCookie();

            controller.ControllerContext = new ControllerContext(context, new RouteData(), controller);

            // Act
            var resultNull  = (RedirectToRouteResult)controller.Update(dataNull);
            var resultEmpty = (RedirectToRouteResult)controller.Update(dataEmpty);

            // Assert
            Assert.AreEqual("Error", resultNull.RouteValues["action"], TestContext.TestName);
            Assert.AreEqual("Error", resultEmpty.RouteValues["action"], TestContext.TestName);
        }
Exemplo n.º 8
0
        public void PostSetsLocationHeader()
        {
            // Arrange
            var controller = new CalendarController();

            controller.Request = new HttpRequestMessage
            {
                RequestUri = new Uri("https://localhost:44352/api/Calendar/Weekday")
            };
            controller.Configuration = new HttpConfiguration();
            controller.Configuration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional });

            controller.RequestContext.RouteData = new HttpRouteData(
                route: new HttpRoute(),
                values: new HttpRouteValueDictionary {
                { "controller", "products" }
            });

            // Act
            List <DateTime> dateList = new List <DateTime> {
                DateTime.Now, DateTime.Now.AddDays(1), DateTime.Now.AddDays(2), DateTime.Now.AddDays(3), DateTime.Now.AddDays(4), DateTime.Now.AddDays(5), DateTime.Now.AddDays(6)
            };
            var weekdayslist = new CommonAPI.CalendarAPI().PostDaysOfWeek(dateList);
            var response     = controller.Post(dateList);

            // Assert
            Assert.AreEqual(weekdayslist.GetType(), response.RequestMessage.Content.GetType());
        }
Exemplo n.º 9
0
        protected void SetUpPage()
        {
            SetContentView(Resource.Layout.CommonLayout);

            #region Controller instantiations

            /*
             * The UserController shouldn't have to be instantiated here, since that would mean that we would lose
             * the currently logged in user. Thus, it should always be in the intent coming into this activity.
             */
            userController = JsonConvert.DeserializeObject <UserController>(Intent.GetStringExtra("UserController"), SerializationBinderHelper.Settings);

            try {
                goalController = JsonConvert.DeserializeObject <GoalController>(Intent.GetStringExtra("GoalController"), SerializationBinderHelper.Settings);
            } catch (ArgumentNullException) {
                goalController = new GoalController();
            }
            try {
                noteController = JsonConvert.DeserializeObject <NoteController>(Intent.GetStringExtra("NoteController"));
            } catch (ArgumentNullException) { noteController = new NoteController(); }
            try {
                fileController = JsonConvert.DeserializeObject <FileController>(Intent.GetStringExtra("FileController"));
            } catch (ArgumentNullException) {
                fileController = new FileController();
            }
            try {
                calendarController = JsonConvert.DeserializeObject <CalendarController>(Intent.GetStringExtra("CalendarController"));
            } catch (ArgumentNullException) {
                calendarController = new CalendarController();
            }
            #endregion
        }
        public async Task Delete_ShouldGetUserNameAndIncludeInMessage()
        {
            //Data
            var guid = Guid.NewGuid();

            //Setup
            _mockUserManagerWrapper.Setup(x => x.FindByNameAsync(It.IsAny <string>()))
            .Returns(Task.FromResult(new User {
                Id = "test"
            })).Verifiable();
            _mockEndpointInstance.Setup(x => x.Send(It.Is <DeleteCalendarEventCommand>(y => y.Id == guid && y.UserId == "test"), It.IsAny <SendOptions>()))
            .Returns(Task.CompletedTask).Verifiable();
            var calendarController = new CalendarController(_mockEndpointInstance.Object, _mockUserManagerWrapper.Object);
            var controllerContext  = new ControllerContext
            {
                HttpContext = _httpContext.Object
            };

            calendarController.ControllerContext = controllerContext;

            //Test
            var result = await calendarController.Delete(guid) as OkResult;

            Assert.NotNull(result);
            Assert.AreEqual(200, result.StatusCode);

            //Analysis
            _mockUserManagerWrapper.Verify();
            _mockEndpointInstance.Verify();
        }
        public async Task Add_ShouldSendToEndpointAndReturnOk()
        {
            //Data
            var model = new CalendarEventModel
            {
                Id           = Guid.Empty,
                Name         = "test",
                LocationName = "testname",
                StartDate    = DateTime.Now,
                EndDate      = DateTime.Now
            };

            //Setup
            _mockEndpointInstance.Setup(x => x.Send(It.Is <AddCalendarEventCommand>(y =>
                                                                                    y.Model.Name == model.Name && y.Model.LocationName == model.LocationName &&
                                                                                    y.Model.StartDate == model.StartDate && y.Model.EndDate == model.EndDate), It.IsAny <SendOptions>()))
            .Returns(Task.CompletedTask).Verifiable();
            _mockUserManagerWrapper.Setup(x => x.FindByNameAsync(It.IsAny <string>())).Returns(Task.FromResult(new User()));
            var calendarController = new CalendarController(_mockEndpointInstance.Object, _mockUserManagerWrapper.Object);
            var controllerContext  = new ControllerContext
            {
                HttpContext = _httpContext.Object
            };

            calendarController.ControllerContext = controllerContext;

            //Test
            var result = await calendarController.Add(model) as OkResult;

            Assert.NotNull(result);
            Assert.AreEqual(200, result.StatusCode);

            //Analysis
            _mockEndpointInstance.Verify();
        }
Exemplo n.º 12
0
    void Start()
    {
        //Debug.LogError("Start");
        _calendarInstance = this;
        Vector3 startPos = m_menuItem.transform.localPosition;

        _dateItems.Clear();
        //_dateItems.Add(m_menuItem);

        for (int i = 0; i < _totalDateNum; i++)
        {
            GameObject item = GameObject.Instantiate(m_menuItem, m_contentRoot) as GameObject;
            item.name = "Item" + (i + 1).ToString();
            //item.transform.SetParent(m_menuItem.transform.parent);
            item.transform.localScale    = Vector3.one;
            item.transform.localRotation = Quaternion.identity;
            item.transform.localPosition = new Vector3((i % 7) * 50 + startPos.x, startPos.y - (i / 7) * 40, startPos.z);

            _dateItems.Add(item.GetComponentInChildren <MenuItem>(true));
        }

        _dateTime = DateTime.Now;

        CreateCalendar();

        _calendarPanel.SetActive(false);
    }
        public void PreviousWeekTest()
        {
            //Setup
            //TimeSpan object that represents 7 days duration
            TimeSpan sevenDays = TimeSpan.FromDays(7);

            //DateTime object that represents the current date - the 7 day TimeSpan (ie, the
            //week before now).
            //                                              Also, rolling back to the start of the week
            //                                              (CalendarController uses Monday as well).
            DateTime expected = DateTime.Now.Subtract(sevenDays).WeekStartDate(DayOfWeek.Monday);

            //String of the total date. (Note: Cannot use DateTime.ToString() methods because do not have full
            //                           access to the DateTime object in the CalendarController).
            string expectedString = expected.Year.ToString() + " " + expected.FullMonthString()
                                    + " " + expected.Day.ToString();


            //Action
            CalendarController.ResetWeek();
            CalendarController.PreviousWeek();

            string actualString = CalendarController.YearString + " " + CalendarController.MonthString
                                  + " " + CalendarController.DayDateString(DayOfWeek.Monday);


            //Test
            Assert.AreEqual(expectedString, actualString);
        }
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
Exemplo n.º 15
0
        public void Controller_Calendar_Update_Post_TimeEnd_Invalid_Should_Send_Back_For_Edit()
        {
            // Arrange
            CalendarController controller = new CalendarController();

            SchoolCalendarModel dataBelowMin = new SchoolCalendarModel
            {
                TimeEnd = TimeSpan.FromHours(0) // less than 1
            };

            SchoolCalendarModel dataAboveMax = new SchoolCalendarModel
            {
                TimeEnd = TimeSpan.FromHours(25) // greater than 24
            };

            var context = CreateMoqSetupForCookie();

            controller.ControllerContext = new ControllerContext(context, new RouteData(), controller);

            // Act
            ViewResult resultBelowMin = controller.Update(dataBelowMin) as ViewResult;
            ViewResult resultAboveMax = controller.Update(dataAboveMax) as ViewResult;

            // Assert
            Assert.IsFalse(controller.ModelState.IsValid);
            Assert.IsNotNull(resultBelowMin, TestContext.TestName);
            Assert.IsNotNull(resultAboveMax, TestContext.TestName);
        }
Exemplo n.º 16
0
        public async Task TestPostCalendarItem()
        {
            using (var context = new BankCalendarContext(options))
            {
                // Given
                CalendarItem calendaritem1 = new CalendarItem {
                    Event = "interview", Location = "Auckland", Start = new System.DateTime(2018, 11, 24, 22, 10, 25), End = new System.DateTime(2018, 11, 24)
                };

                // When
                CalendarController calendarController = new CalendarController(context);
                IActionResult      result             = await calendarController.PostCalendarItem(calendaritem1) as IActionResult;

                // Then
                var okObjectResult = result as OkObjectResult;
                Assert.IsNotNull(okObjectResult);

                var model = okObjectResult.Value as CalendarItem;
                Assert.IsNotNull(model);
                Assert.AreNotEqual(0, model.ID);
                Assert.AreEqual(calendaritem1.Event, model.Event);
                Assert.AreEqual(calendaritem1.Location, model.Location);
                Assert.AreEqual(calendaritem1.Start, model.Start);
                Assert.AreEqual(calendaritem1.End, model.End);

                Assert.AreEqual(true, context.CalendarItem.Any(x => x.ID == model.ID));
            }
        }
        public void indexViewTest()
        {
            CalendarController calendarController = initCalendarController(existentUserId);
            ViewResult         result             = calendarController.Index(existentProjectId) as ViewResult;

            Assert.AreEqual("Index", result.ViewName);
        }
Exemplo n.º 18
0
        public void Get_DefaultsNumberOfWeeks_IfNotSupplied()
        {
            _calendarServiceMock.Setup(mock => mock.Get(123, 8));
            var calendarController = new CalendarController(_calendarServiceMock.Object);
            var response           = calendarController.Get(123, null);

            _calendarServiceMock.Verify(mock => mock.Get(123, 8), Times.Once());
        }
Exemplo n.º 19
0
        public void Get_ThrowsBadRequest_IfNoStartDateSupplied()
        {
            var calendarController      = new CalendarController(_calendarServiceMock.Object);
            var response                = calendarController.Get(null, null);
            var httpStatusCodeException = (ErrorHandlerMiddleware.HttpStatusCodeException)response.Exception.InnerException;

            Assert.Equal(HttpStatusCode.BadRequest, httpStatusCodeException.StatusCode);
        }
Exemplo n.º 20
0
        public void GetEventFromIDTestType()
        {
            var calendar = new CalendarController("http://localhost:5001/api/");

            var result = calendar.GetEvent("2");

            Assert.IsInstanceOfType(result, typeof(JsonResult));
        }
Exemplo n.º 21
0
 override public void Show()
 {
     base.Show();
     calendarController = CalendarController.Instance;
     monthShowing       = calendarController.CurrentDate.Month;
     UpdateCalendar();
     UpdateNavigation();
 }
        public async Task GetNonExistingDay()
        {
            int id         = 1000;
            var controller = new CalendarController(unit.Context);

            var response = await controller.Get(id) as ObjectResult;

            Assert.AreEqual(404, response.StatusCode);
        }
        public void getRequirementsTest()
        {
            CalendarController calendarController = initCalendarController(existentUserId);
            ViewResult         result             = calendarController.Index(existentProjectId) as ViewResult;

            List <CalendarData> list = (List <CalendarData>)result.Model;

            Assert.IsTrue(list.Count > 0);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Sets the controls
        /// </summary>
        /// <param name="parentId">The parent id</param>
        /// <param name="controls">The controls</param>
        /// <param name="controller">The controller to use</param>
        public void SetControls(string parentId, ControlsAccess controls, EventViewController controller, string calendarId)
        {
            _controls = controls;
            _parentId = parentId;
            _events   = controller;
            _calendar = (CalendarController)_controls.Get(parentId, calendarId);

            Setup();
        }
        public void getRequirementsNoUserNoProjectTest()
        {
            CalendarController calendarController = initCalendarController("");
            ViewResult         result             = calendarController.Index(null) as ViewResult;

            List <CalendarData> list = (List <CalendarData>)result.Model;

            Assert.IsFalse(list.Count > 0);
        }
        public void DayIndexForMondayStartTestWithMonday()
        {
            //Creating a new date for Monday, April 29th, 2019
            DateTime testDate = new DateTime(2019, 4, 29);

            //Monday should be represented by a 0
            int expected = 0;

            Assert.AreEqual(expected, CalendarController.DayIndexForMondayWeekStart(testDate.DayOfWeek));
        }
        public void DayIndexForMondayStartTestWithSunday()
        {
            //Creating a new date for Sunday, May 5th, 2019
            DateTime testDate = new DateTime(2019, 5, 5);

            //Sunday should be represented by a 6
            int expected = 6;

            Assert.AreEqual(expected, CalendarController.DayIndexForMondayWeekStart(testDate.DayOfWeek));
        }
Exemplo n.º 28
0
    public void OnButtonSelected()
    {
        CalendarController cpc = gameObject.transform.parent.parent.GetComponent <CalendarController> ();
        int month = PlayerPreferences.TranslateMonth(cpc._month.text);
        int year  = int.Parse(cpc._year.text);
        int day   = int.Parse(dayText.gameObject.name);

        DataManager.dateNewAppointment = new DateTime(year, month, day);
        PageNavFrameWork.PageNav.GetPageNavInstance().PushPageToStack(PageNavFrameWork.PagesEnum.ScheduleDetailPage);
    }
Exemplo n.º 29
0
    public override void Init(IModule module)
    {
        base.Init(module);
        var viewScript = InstantiateView <CalendarView>("LoveDiary/Prefabs/CalendarView");

        _calendarController = new CalendarController();
        RegisterController(_calendarController);
        _calendarController.CurCalendarView = (CalendarView)viewScript;
        _calendarController.Start();
    }
Exemplo n.º 30
0
        public async void TestGetCalendar()
        {
            Logic logic = new Logic();
            CalendarController calendarController = new CalendarController(null);


            var getCalendar = await calendarController.GetCalendar();

            Assert.NotNull(getCalendar);
        }
Exemplo n.º 31
0
        public void Index()
        {
            // Arrange
            CalendarController controller = new CalendarController();

            // Act
            ViewResult result = controller.Index() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
Exemplo n.º 32
0
        public void About()
        {
            // Arrange
            CalendarController controller = new CalendarController();

            // Act
            ViewResult result = controller.About() as ViewResult;

            // Assert
            Assert.AreEqual("Your application description page.", result.ViewBag.Message);
        }
Exemplo n.º 33
0
    void Awake()
    {
        refurbishmentTab = controller.transform.FindChild ("RefurbishmentCTR").gameObject.GetComponent<Refurbishment>();
        staffMenu = GameObject.FindGameObjectWithTag ("StaffingController").GetComponent<StaffMenu> ();
        bankingTab = controller.transform.FindChild ("BankingController").gameObject.GetComponent<BankingReport>();
        emsTab = controller.transform.FindChild("EMSController").gameObject.GetComponent<EMSReport>();
        revenueManagementTab = controller.transform.FindChild("RevenueManagerCTR").GetComponent<RevenueManagement>();
        randomEvent = controller.transform.FindChild("EventController").GetComponent<RandomEvent>();
        rateSetup = controller.transform.FindChild("RatesSetUp").GetComponent<RatesSetup>();
        groupController = controller.transform.FindChild("GroupBooking").GetComponent<GroupBookController>();
        calendarController = controller.transform.FindChild("CalendarController").GetComponent<CalendarController>();
        feedbackController = controller.transform.FindChild("FeedBackController").GetComponent<FeedbackController>();
        dataProcessor = GameObject.Find("DataCollection").GetComponent<Serializer_Deserializer>();
        assetSwapper = controller.transform.FindChild("AssetController").GetComponent<AssetSwapper>();
        toolbar = GameObject.FindGameObjectWithTag("UI").transform.FindChild("OverWorld").GetComponent<ToolbarOptions>();
        adController = controller.transform.FindChild("AdvertController").gameObject.GetComponent<Advertisment>();

        SingletonCheck();
        if(monthlyReports == null){
            monthlyReports = new List<MonthlyReport>();//create list on first run.
        }
        //Ensure there's a log for this week (special case for 1st time run)
        if (receptionLogs == null) {
            receptionLogs = new List<ReceptionLog> ();
        }
        if(restaurantBooks == null){
            restaurantBooks = new List<RestaurantBook>();//create a new list on first run.
        }
        //Ensure there's a log for this week (special case for 1st time run)
        if (staffingLogs == null) {
            staffingLogs = new List<StaffingLog> ();
        }
        //create the log once.
        if(balanceSheets == null){
            balanceSheets = new List<BalanceSheet>();//create new balance sheet list on first run.
        }
        GenerateNewMonthReports ();
        firstGeneration = true;

        medianRoomCostWD = rateSetup.medianRoomCostWD;
        medianRoomCostWE = rateSetup.medianRoomCostWE;
    }