コード例 #1
0
        public void Edit_EditTicketOne_ReturnsViewEdit()
        {
            //Arrange

            //Act
            var result = controller.Edit(1) as ViewResult;

            //Assert
            Ticket t = (Ticket)result.ViewData.Model;

            Assert.AreEqual("Edit", result.ViewName);
            Assert.AreEqual(1, t.TicketNumber);
        }
コード例 #2
0
        public void TicketEditTest()
        {
            var ac = new TicketController();
            var r  = ac.Edit(1) as ViewResult;

            Assert.IsNotNull(r);
        }
コード例 #3
0
        public void Edit_WithValidId_ReturnsViewResultWithTicket()
        {
            // arrange
            int ticketId = 1;
            var mgr      = new Mock <ITicketManager>();

            mgr
            .Setup(x => x.GetTicket(ticketId))
            .Returns(TestTicketsProvider.GetTestTickets().FirstOrDefault(ticket => ticket.TicketNumber == ticketId));
            var controller = new TicketController(mgr.Object);
            var ticketThatShouldBeReturned = TestTicketsProvider.GetTestTickets().First(t => t.TicketNumber == ticketId);

            // act
            var result = controller.Edit(ticketId);

            // assert
            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsType <Ticket>(viewResult.Model);

            Assert.Equal(ticketThatShouldBeReturned.TicketNumber, model.TicketNumber);
            Assert.Equal(ticketThatShouldBeReturned.AccountId, model.AccountId);
            Assert.Equal(ticketThatShouldBeReturned.Text, model.Text);
            Assert.Equal(ticketThatShouldBeReturned.DateOpened, model.DateOpened);
            Assert.Equal(ticketThatShouldBeReturned.State, model.State);
//			Assert.Equal(ticketThatShouldBeReturned.Responses, model.Responses);
//			bool responesEqual = ticketThatShouldBeReturned.Responses.SequenceEqual(model.Responses);
//			Assert.True(responesEqual);
        }
コード例 #4
0
        public void Edit_PassesTicketInEditViewModelAndReturnsSelectListsOfTicketTypesAndContracts()
        {
            _gebruikerRepository.Setup(m => m.GetByTicketNr(1)).Returns(_dummyContext.t);
            _ticketTypeRepository.Setup(m => m.GetAll()).Returns(_dummyContext.TicketTypes);
            _gebruikerRepository.Setup(m => m.GetAllContracten()).Returns(_dummyContext.Contracten);
            var result                = Assert.IsType <ViewResult>(_controller.Edit(1));
            var ticketEvm             = Assert.IsType <TicketEditViewModel>(result.Model);
            var ticketTypesInViewData = Assert.IsType <SelectList>(result.ViewData["ticketTypes"]);
            var contractenInViewData  = Assert.IsType <SelectList>(result.ViewData["contractenKlant"]);

            Assert.Equal("Titel ticketP1", ticketEvm.Titel);
            Assert.Equal(1, ticketEvm.TicketTypeId);
            Assert.Equal(3, ticketTypesInViewData.Count());
            Assert.Equal(1, ticketEvm.ContractId);
            Assert.Equal(3, contractenInViewData.Count());
        }
コード例 #5
0
        public void TicketEditTest()
        {
            // act
            var result = _ticketController.Edit(new TicketViewModel());

            // asssert
            Assert.IsNotNull(result);
        }
コード例 #6
0
ファイル: EditShould.cs プロジェクト: CopperBeardy/SEPUNI
        public async void ReturnValidModelForCorrectId(string id)
        {
            var result = await sut.Edit(id);

            var vr = Assert.IsType <ViewResult>(result);

            fixture.repositoryWrapper.Verify(y => y.Ticket.GetTicketByIdAsync(id), Times.Once);
            Assert.Equal("Edit", vr.ViewName);
            Assert.IsAssignableFrom <TicketManagementDTO>(vr.Model);
        }
コード例 #7
0
        public void Edit_WithInvalidId_ReturnsNullAsViewResult()
        {
            // arrange
            int ticketId = 1;
            var mgr      = new Mock <ITicketManager>();

            mgr
            .Setup(x => x.GetTicket(ticketId))
            .Returns((Ticket)null);
            var controller = new TicketController(mgr.Object);

            // act
            var result = controller.Edit(ticketId);

            // assert
            var viewResult = Assert.IsType <ViewResult>(result);

            Assert.Null(viewResult.Model);
        }
コード例 #8
0
 public void ControllerEditMethod_WithOnlyIdAsParameter_CallsMgrToGetTicket()
 {
     _controller.Edit(15);
     mgr.Received().GetTicket(15);
 }