Beispiel #1
0
        public async Task AddSession_HappyPath_ShouldReturnOk()
        {
            //Arrange
            var endDate            = DateTime.Now;
            var startDate          = DateTime.Now.AddDays(-1);
            var newSession         = new AddSessionDto();
            var mockSessionService = A.Fake <ISessionService>();

            A.CallTo(() => mockSessionService.AddSession(newSession)).Returns(
                new ServiceResponse <List <GetSessionDto> >
            {
                Data = new List <GetSessionDto>
                {
                    new GetSessionDto
                    {
                        Id            = 1,
                        StartDateTime = startDate,
                        EndDateTime   = endDate
                    }
                }
            });
            var controller = new SessionController(mockSessionService);

            //Act
            var result = await controller.AddSession(newSession);

            var okResult     = result as OkObjectResult;
            var actualResult = okResult.Value as ServiceResponse <List <GetSessionDto> >;

            //Assert
            Assert.AreEqual(typeof(OkObjectResult), result.GetType());
            Assert.AreEqual(1, actualResult.Data[0].Id);
            Assert.AreEqual(startDate, actualResult.Data[0].StartDateTime);
            Assert.AreEqual(endDate, actualResult.Data[0].EndDateTime);
        }
        public override void ChannelActive(IChannelHandlerContext context)
        {
            Session session = sessionFactory.CreateSession(context.Channel);

            sessionController.AddSession(session);

            logger.LogInformation("New connection from {0}", session.Channel.RemoteAddress);
        }
Beispiel #3
0
        public async Task AddSession_HappyPath_ShouldReturnBadRequest()
        {
            //Arrange
            var newSession         = new AddSessionDto();
            var mockSessionService = A.Fake <ISessionService>();

            A.CallTo(() => mockSessionService.AddSession(newSession)).Returns(
                new ServiceResponse <List <GetSessionDto> >
            {
                Data = null
            });
            var controller = new SessionController(mockSessionService);

            //Act
            var result = await controller.AddSession(newSession);

            //Assert
            Assert.AreEqual(typeof(BadRequestObjectResult), result.GetType());
        }
Beispiel #4
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         bool isvalidated = validatefields();
         if (isvalidated)
         {
             Session session = new Session();
             session.tag    = comboTag.SelectedItem.ToString();
             session.sgroup = comboGroup.SelectedItem.ToString();
             //subject start
             DataRowView drv = (DataRowView)comboSubject.SelectedItem;
             session.subject = drv.Row.ItemArray[1].ToString();
             //subject end
             session.noofstudent = Convert.ToInt32(txtNoOfStudent.Text);
             session.duration    = Convert.ToInt32(txtDuration.Text);
             List <int> selectedLectList = new List <int>();
             for (int i = 0; i < listSelectedLecturers.Items.Count; i++)
             {
                 MyItem myItem = (MyItem)listSelectedLecturers.Items[i];
                 selectedLectList.Add(myItem.value);
             }
             string message = SessionController.AddSession(session, selectedLectList);
             MessageBox.Show(message);
             clear();
         }
         else
         {
             MessageBox.Show("please fill in all fields!");
         }
     }
     catch (NullReferenceException nre)
     {
         MessageBox.Show("please fill in all fields!");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        public void CreateSession_Success()
        {
            dal.AddUser(new User());           // id = 1
            dal.AddSprydZone(new SprydZone()); // id = 1
            UserSession newSessionParameters = new UserSession()
            {
                UserId    = 1,
                SessionId = 1,
                Session   = new Session()
                {
                    SprydZoneId = 1
                }
            };

            Session newSession = sessionController.AddSession(newSessionParameters);

            Assert.AreEqual(dal.GetSessionById(1), newSession);
            Assert.AreEqual(dal.GetSessionAllUsers(newSession.Id).First().Id, 1);
        }