Beispiel #1
0
        public void All_Should_ReturnOnlyPublicConferences()
        {
            //Three public conferences, one private
            _context.Conferences.Add(new Conference()
            {
                HashTag = "test", Name = "test", Abstract = "test", StartDate = DateTime.Now, EndDate = DateTime.Now, TimeZoneId = "test", AvailableToPublic = true
            });
            _context.Conferences.Add(new Conference()
            {
                HashTag = "test", Name = "test", Abstract = "test", StartDate = DateTime.Now, EndDate = DateTime.Now, TimeZoneId = "test", AvailableToPublic = true
            });
            _context.Conferences.Add(new Conference()
            {
                HashTag = "test", Name = "test", Abstract = "test", StartDate = DateTime.Now, EndDate = DateTime.Now, TimeZoneId = "test", AvailableToPublic = true
            });
            _context.Conferences.Add(new Conference()
            {
                HashTag = "test", Name = "test", Abstract = "test", StartDate = DateTime.Now, EndDate = DateTime.Now, TimeZoneId = "test", AvailableToPublic = false
            });
            _context.SaveChangesWithErrors();


            var conferenceController = new ConferenceController(_context);

            var result = conferenceController.All()
                         .As <ViewResult>();

            result.Model
            .As <IEnumerable <Conference> >()
            .Should().HaveCount(3);
        }
Beispiel #2
0
        public void GivenAnIndexAction_ThenRenderTheDefaultView()
        {
            var controller = new ConferenceController();

            controller.WithCallTo(c => c.Index())
            .ShouldRenderDefaultView();
        }
        public void Conference_Add()
        {
            // Arrange
            string section = "DPRO";
            var    info    = new InfoItem
            {
                Name     = "DevPRO",
                City     = "Tomsk",
                Location = "ul. Naberejnaya reki Ushaiky, 12 (IAM TSU)"
            };

            using (var context = GetContextWithData())
                using (var controller = new ConferenceController(context))
                {
                    // Act
                    var result = controller.Create(section, info);

                    // Assert
                    var createdResult = result.Should().BeOfType <CreatedAtRouteResult>().Subject;
                    var item          = createdResult.Value.Should().BeAssignableTo <ConferenceItem>().Subject;

                    item.Section.Should().Be("DPRO");
                    item.Info.Name.Should().Be("DevPRO");
                    item.Info.City.Should().Be("Tomsk");
                    item.Info.Location.Should().Be("ul. Naberejnaya reki Ushaiky, 12 (IAM TSU)");
                }
        }
        public void SetUp()
        {
            _mockCallCreator     = new Mock <ICallCreator>();
            _mockCallsRepository = new Mock <ICallsRepository>();
            _mockCallsRepository.Setup(c => c.FindByAgentIdAsync("agent2"))
            .ReturnsAsync(new Call("agent2", "conference-id"));

            Mock <HttpContextBase> httpContextMock = new Mock <HttpContextBase>();
            Mock <HttpRequestBase> httpReguestMock = new Mock <HttpRequestBase>();
            var headers = new NameValueCollection();

            headers.Add("Origin", "example.com");
            httpReguestMock.Setup(r => r.Headers).Returns(headers);
            httpContextMock.SetupGet(c => c.Request).Returns(httpReguestMock.Object);

            _controller = new ConferenceController(
                _mockCallCreator.Object, _mockCallsRepository.Object)
            {
                ControllerContext = MockControllerContext(),
                Url = MockUrlHelper(),
            };

            _controller.ControllerContext = new ControllerContext(
                httpContextMock.Object,
                new RouteData(),
                _controller);
        }
Beispiel #5
0
        public void Details_ValidId_ReturnsViewModel()
        {
            // arrange
            int conferenceId             = 1;
            var conferenceRepositoryMock = new Mock <IConferenceRepository>();

            conferenceRepositoryMock.Setup(c => c.GetBy(It.IsAny <int>()))
            .Returns(new Conference
            {
                IdConference = 1,
                Name         = "test name",
                Description  = "desc"
            });

            conferenceController = new ConferenceController(conferenceRepositoryMock.Object);

            // act
            var viewModel = (conferenceController.Details(conferenceId) as ViewResult).Model
                            as ConferenceViewModel;

            // asert
            Assert.Equal(1, viewModel.IdConference);
            Assert.Equal("test name", viewModel.Name);
            Assert.Equal("desc", viewModel.Description);
        }
 public HttpResponseMessage Participant(int conferenceId, int id, NBrightOrderItem data)
 {
     if (data.AttendeeUserId == null)
     {
         var userId = data.UserID;
         if (userId == null)
         {
             userId = data.AlternativeUserId;
         }
         if (userId == null)
         {
             userId = -1;
         }
         ConferenceController.AddAttendee(PortalSettings.PortalId,
                                          conferenceId,
                                          (int)userId,
                                          data.Email,
                                          data.FirstName,
                                          data.LastName,
                                          string.Format("{0} {1}", data.FirstName, data.LastName),
                                          data.Company,
                                          UserInfo.UserID);
     }
     else
     {
         AttendeeRepository.Instance.DeleteAttendee(conferenceId, (int)data.AttendeeUserId);
     }
     return(Request.CreateResponse(HttpStatusCode.OK, NBrightRepository.Instance.GetOrderItems(conferenceId, id)));
 }
Beispiel #7
0
        public void GetAll_RetrieveAllConferencesInDb_AllConferences()
        {
            var conferences = new List <Conference>()
            {
                new Conference()
                {
                    DisplayName = "Eva's conference",
                    StartDate   = DateTime.UtcNow,
                    EndDate     = DateTime.UtcNow
                },
                new Conference()
                {
                    DisplayName = "Grant's conference",
                    StartDate   = DateTime.UtcNow,
                    EndDate     = DateTime.UtcNow,
                }
            };

            var mockConferenceService = new Mock <IConferenceService>();

            mockConferenceService.Setup(m => m.GetAll()).Returns(conferences);

            var conferenceController = new ConferenceController(mockConferenceService.Object);
            var result = conferenceController.GetAllConferences().Value;

            Assert.AreEqual(conferences.Count, result.Count());

            foreach (var conf in conferences)
            {
                Assert.IsTrue(result.Contains(conf));
            }

            mockConferenceService.Verify(cs => cs.GetAll(), Times.Once());
        }
Beispiel #8
0
        public void Details_WithInvalidHashTag_Should_ReturnHttpNotFoundResult()
        {
            var conferenceController = new ConferenceController(_context);

            var result = conferenceController.Details("thisisinvalid")
                         .As <HttpNotFoundResult>();
        }
Beispiel #9
0
        public void Details_WithValidHashTag_Should_ReturnCorrectConference()
        {
            var stubConference = new Conference()
            {
                HashTag = "abcde", Name = "test", Abstract = "test", StartDate = DateTime.Now, EndDate = DateTime.Now, TimeZoneId = "test", AvailableToPublic = true
            };

            _context.Conferences.Add(stubConference);
            _context.Conferences.Add(new Conference()
            {
                HashTag = "test", Name = "test", Abstract = "test", StartDate = DateTime.Now, EndDate = DateTime.Now, TimeZoneId = "test", AvailableToPublic = false
            });
            _context.SaveChangesWithErrors();;

            var conferenceController = new ConferenceController(_context);

            conferenceController.ControllerContext = TestHelper.MockContext(conferenceController, "TestUser");

            var result = conferenceController.Details("abcde")
                         .As <ViewResult>();

            result.Model
            .As <Conference>()
            .Should()
            .Be(stubConference);
        }
Beispiel #10
0
        public ConferenceControllerTests()
        {
            // Arrange
            mockService = new Mock <IConferenceService>();
            mockService.Setup(x => x.GetAllSessions()).Returns(Task.Run(() => (GetSessionResults().AsEnumerable())));
            mockService.Setup(x => x.GetSessionById(It.Is <int>(i => i > int.MinValue))).Returns(Task.Run(() => GetSessionResults().First()));

            confLogger = new NullLogger <ConferenceController>();

            controller = new ConferenceController(mockService.Object, confLogger);
        }
Beispiel #11
0
        public void GetAll_NothingInDb_EmptyResult()
        {
            var mockConferenceService = new Mock <IConferenceService>();

            mockConferenceService.Setup(c => c.GetAll()).Returns(new List <Conference>());
            var conferenceController = new ConferenceController(mockConferenceService.Object);
            var result = conferenceController.GetAllConferences().Value;

            Assert.AreEqual(0, result.Count());
            mockConferenceService.Verify(cs => cs.GetAll(), Times.Once());
        }
Beispiel #12
0
        public void DeleteConference()
        {
            // Arrange
            ConferenceController controller = new ConferenceController();

            var actResult = controller.Delete(1);
            // Act
            var result = actResult as OkNegotiatedContentResult <bool>;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Content == true);
        }
Beispiel #13
0
        public void getConference()
        {
            // Arrange
            ConferenceController controller = new ConferenceController();

            var actResult = controller.Get(1);
            // Act
            var result = actResult as OkNegotiatedContentResult <Conference>;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Content.ID == 1);
        }
        public void should_unit_the_conference_service_to_return_the_conference_data()
        {
            var theConferenceInfo = new ConferenceInfo();
            var conferenceService = new Mock <IConferenceService>();

            conferenceService.Setup(x => x.ConferenceInfo()).Returns(theConferenceInfo);
            var controller = new ConferenceController(conferenceService.Object);

            var result = controller.Get();

            Assert.IsType <ConferenceInfo>(result);
            Assert.Equal(result, theConferenceInfo);
        }
        public void Info_Get_Specific_Invalid()
        {
            // Arrange
            using (var context = GetContextWithData())
                using (var controller = new ConferenceController(context))
                {
                    // Act
                    var result = controller.GetById("USSR");

                    // Assert
                    result.Should().BeOfType <NotFoundResult>();
                }
        }
Beispiel #16
0
        public void GivenAJoinAction_ThenTheResponseContainsAGatherVerb()
        {
            var controller = new ConferenceController {
                Url = Url
            };
            var result = controller.Join();

            result.ExecuteResult(MockControllerContext.Object);
            var document = BuildDocument();

            Assert.That(document.SelectSingleNode("Response/Gather").Attributes["action"].Value,
                        Is.EqualTo("/Conference/Connect"));
        }
Beispiel #17
0
        public void GetById_WrongId_Null()
        {
            var mockConferenceService = new Mock <IConferenceService>();

            mockConferenceService.Setup(c => c.GetByUniqueName(It.IsAny <string>())).Returns((Conference)null);

            var conferenceController = new ConferenceController(mockConferenceService.Object);
            var result = conferenceController.GetConferenceByUniqueName("6aa2b0c4a3a3e850dc1b9a62").Value;

            mockConferenceService.Verify(
                c => c.GetByUniqueName(It.Is <string>(id => id == "6aa2b0c4a3a3e850dc1b9a62")),
                Times.Once());
            Assert.IsNull(result);
        }
Beispiel #18
0
        public void SetUp()
        {
            _mockCallCreator     = new Mock <ICallCreator>();
            _mockCallsRepository = new Mock <ICallsRepository>();
            _mockCallsRepository.Setup(c => c.FindByAgentIdAsync("agent2"))
            .ReturnsAsync(new Call("agent2", "conference-id"));

            _controller = new ConferenceController(
                _mockCallCreator.Object, _mockCallsRepository.Object)
            {
                ControllerContext = MockControllerContext(),
                Url = MockUrlHelper(),
            };
        }
Beispiel #19
0
        public async Task SpeakersAndSessionsAsyncShouldReturnOkResult()
        {
            //Arrange
            var mockConferenceService = new Mock <IConferenceService>();

            mockConferenceService.Setup(service => service.GetSpeakersAndSessionsAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync(new JObject());

            var controller = new ConferenceController(mockConferenceService.Object);

            // Act
            var data = await controller.SpeakersAndSessionsAsync();

            // Assert
            Assert.IsType <Microsoft.AspNetCore.Mvc.OkObjectResult>(data);
        }
        public void Conferences_Get_All()
        {
            // Arrange
            using (var context = GetContextWithData())
                using (var controller = new ConferenceController(context))
                {
                    // Act
                    var result = controller.GetAll();

                    // Assert
                    var okResult = result.Should().BeOfType <OkObjectResult>().Subject;
                    var items    = okResult.Value.Should().BeAssignableTo <IEnumerable <ConferenceItem> >().Subject;

                    items.Count().Should().Be(3);
                }
        }
Beispiel #21
0
        public async Task SessionAsyncShouldReturnBadRequest()
        {
            //Arrange
            var mockConferenceService = new Mock <IConferenceService>();

            mockConferenceService.Setup(service => service.GetSessionByIdAsync(It.IsAny <int>())).ReturnsAsync(new JObject());

            var controller = new ConferenceController(mockConferenceService.Object);
            int id         = -1;

            //Act
            var data = await controller.GetAsync(id);

            //Assert
            Assert.IsType <Microsoft.AspNetCore.Mvc.BadRequestResult>(data);
        }
        public void Info_Get_Specific()
        {
            // Arrange
            using (var context = GetContextWithData())
                using (var controller = new ConferenceController(context))
                {
                    // Act
                    var result = controller.GetById("GIS");

                    // Assert
                    var okResult = result.Should().BeOfType <OkObjectResult>().Subject;
                    var item     = okResult.Value.Should().BeAssignableTo <InfoItem>().Subject;

                    item.Name.Should().Be("Geoinformation Systems");
                }
        }
Beispiel #23
0
        public void GetById_ValidId_CorrectConference()
        {
            var mockConferenceService = new Mock <IConferenceService>();
            var conference            = new Conference()
            {
                DisplayName = "Oliver Wheeler's Conference",
                StartDate   = DateTime.UtcNow,
                EndDate     = DateTime.UtcNow,
                UniqueName  = "5dd2b0c4a3a3e850dc1b9c55",
            };

            mockConferenceService.Setup(c => c.GetByUniqueName(It.IsAny <string>())).Returns(conference);

            var conferenceController = new ConferenceController(mockConferenceService.Object);
            var result = conferenceController.GetConferenceByUniqueName("5dd2b0c4a3a3e850dc1b9c55").Value;

            Assert.AreEqual(conference, result);
        }
Beispiel #24
0
        public void Add_FullConference_CallToConferencService()
        {
            var mockConferenceService = new Mock <IConferenceService>();

            mockConferenceService.Setup(c => c.Add(It.IsAny <Conference>()));

            var conferenceController = new ConferenceController(mockConferenceService.Object);
            var conferenceToAdd      = new Conference()
            {
                DisplayName = "Eva's Conference",
                StartDate   = DateTime.UtcNow,
                EndDate     = DateTime.UtcNow
            };

            conferenceController.Post(conferenceToAdd);
            mockConferenceService.Verify(
                c => c.Add(It.Is <Conference>(conf => conf == conferenceToAdd)),
                Times.Once());
        }
Beispiel #25
0
        public void Controller_AddConference_ReturnsNewConferenceAsLast()
        {
            var repository = ServiceProvider.GetRequiredService <IConferenceRepository>();
            var controller = new ConferenceController(repository);

            // create new conference
            var result = controller.Create(new Web.Models.ConferenceViewModel
            {
                Name        = "test Conf",
                Description = "hello"
            }) as RedirectToActionResult;

            Assert.Equal("Conference", result.ControllerName);
            Assert.Equal("Index", result.ActionName);

            // get last conference
            var conferenceList      = (controller.Index() as ViewResult).Model as IEnumerable <ConferenceViewModel>;
            var conferenceViewModel = conferenceList.Last();

            Assert.Equal("test Conf", conferenceViewModel.Name);
            Assert.Equal("hello", conferenceViewModel.Description);
        }
Beispiel #26
0
        public void GivenAConnectAction_ThenGeneratesTheAppropriateResponse(
            string selectedOption,
            string expectedMute,
            string expectedStartConferenceOnEnter,
            string expectedEndConferenceOnEnter)
        {
            var controller = new ConferenceController();
            var result     = controller.Connect(selectedOption);

            result.ExecuteResult(MockControllerContext.Object);
            var document = BuildDocument();

            var conferenceAttributes = document
                                       .SelectSingleNode("Response/Dial/Conference").Attributes;

            Assert.That(conferenceAttributes["muted"].Value,
                        Is.EqualTo(expectedMute));
            Assert.That(conferenceAttributes["startConferenceOnEnter"].Value,
                        Is.EqualTo(expectedStartConferenceOnEnter));
            Assert.That(conferenceAttributes["endConferenceOnExit"].Value,
                        Is.EqualTo(expectedEndConferenceOnEnter));
        }
Beispiel #27
0
        public void PostConference()
        {
            // Arrange
            ConferenceController controller = new ConferenceController();

            Conference ConferenceObj = new Conference
            {
                Title           = "Project Meeting",
                IsDeleted       = false,
                Description     = "This is Project Status Metting",
                EndTime         = new DateTime(2016, 11, 11, 15, 00, 00),
                StartTime       = new DateTime(2016, 11, 11, 14, 00, 00),
                SpecialComments = "This is Special Comments",
            };
            var actResult = controller.Post(ConferenceObj);
            // Act
            var result = actResult as OkNegotiatedContentResult <Conference>;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Content.ID > 0);
        }
        public void Conference_Add_Invalid()
        {
            // Arrange
            string section = "DPRODPRO";
            var    info    = new InfoItem
            {
                Name     = "DevPRO",
                City     = "Tomsk",
                Location = "ul. Naberejnaya reki Ushaiky, 12 (IAM TSU)"
            };

            using (var context = GetContextWithData())
                using (var controller = new ConferenceController(context))
                {
                    // Act
                    var result = controller.Create(section, info);

                    // Assert
                    var createdResult = result.Should().BeOfType <BadRequestObjectResult>().Subject;
                    var item          = createdResult.Value.Should().BeAssignableTo <SerializableError>().Subject;
                    item.ContainsKey("Section").Should().Be(true);
                }
        }
Beispiel #29
0
        public void Create_WithAlreadyUsedHashTag_Should_ReturnViewAndAddModelError()
        {
            _context.Conferences.Add(new Conference()
            {
                HashTag = "abcde", Name = "test", Abstract = "test", StartDate = DateTime.Now, EndDate = DateTime.Now, TimeZoneId = "test", AvailableToPublic = false
            });
            _context.SaveChangesWithErrors();

            var conferenceController = new ConferenceController(_context);

            var newConference = new Conference()
            {
                HashTag = "abcde"
            };
            var result = conferenceController.Create(newConference)
                         .As <ViewResult>();

            result.ViewData.ModelState["HashTag"]
            .Errors
            .Count
            .Should()
            .Be(1);
        }
        private void initData()
        {
            conferenceController = new ConferenceController(dataFormDTO.db);
            filter = new ConferenceFilter();

            conferenceCrud = new ConferenceCrud(dataFormDTO.db);

            formDTO          = new CUConferenceFormDTO();
            formDTO.contex   = dataFormDTO.db;
            formDTO.obj      = new conference();
            formDTO.userData = dataFormDTO.userData;

            CheckBoxDataInit dataInit = new CheckBoxDataInit(dataFormDTO.db);

            filter.date = DateTime.Now;
            dataInit.addConferences(cbConference);
            dataInit.addAddresses(cbAddress);
            dataInit.addCountries(cbCountry);

            if (!(dataFormDTO.userData.userRole == UserRole.ADMIN ||
                  dataFormDTO.userData.userRole == UserRole.CONFERENCE_MANAGER))
            {
                AddConferenceButton.Visible = false;

                updButton.Visible = false;
                delButton.Visible = false;
            }
            else
            {
                AddConferenceButton.Visible = true;

                updButton.Visible = true;
                delButton.Visible = true;
            }

            //dataGridView1.DataSource = db.ViewConferences.ToList();
        }