public void UserViewController_Post_Returns_Created(UserView userViews)
        {
            #region Arrange

            SetupUserIdentity();
            userViewRepository = new Mock <IUserViewRepository>();
            //SetupUserViewRepository(out Mock<IUserViewRepository> userviewsRepository);

            var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPPOST), $"{AppSettings.BASEURL}{RouteHelper.UserviewRoutePrefix}");
            UserViewController userviewController = CreateUserViewController(httpRequest, userViewRepository.Object, userViewScreenRepository.Object);

            var userviewdata = new grs_TblUserview()
            {
                ViewId     = 101,
                Userid     = 100,
                Default    = false,
                Screenname = "GRS.UW_Workbench",
                Viewname   = "mysubmissions",
                Layout     = "SomeJason",
                Customview = false,
                Sortorder  = 1
            };

            grs_TblUserview nullData = null;
            userViewRepository.SetupSequence(p => p.Get(It.IsAny <Expression <Func <grs_TblUserview, bool> > >()))
            .Returns(nullData)
            .Returns(userviewdata);

            #endregion

            #region Act

            var response = userviewController.Post(userViews);

            #endregion

            #region Expected Data

            var expectedUserViewdata =
                new UserView()
            {
                ViewId     = 101,
                UserId     = 100,
                Default    = false,
                ScreenName = "GRS.UW_Workbench",
                ViewName   = "mysubmissions",
                Layout     = "SomeJason",
                CustomView = false,
                SortOrder  = 1
            };

            #endregion

            #region Assert
            var contentResult = response as NegotiatedContentResult <ResponseItem <UserView> >;
            Assertions.AssertCreatedResponse(contentResult);
            var usrViewData = contentResult.Content.data;

            //Data
            var actualUserViewdata = usrViewData;
            Assertions.AssertData(expectedUserViewdata, actualUserViewdata);


            //Links & Messages
            //  Assert.IsEmpty(contentResult.Content.links);
            Assert.IsEmpty(contentResult.Content.messages);
            #endregion
        }
Ejemplo n.º 2
0
        public void DealNotesController_Post_Returns_CreatedCode(Notes dealNotes)
        {
            #region Arrange
            SetupUserIdentity();

            SetupDealNotesRepo(out Mock <ITbDealNotesRepository> dealNotesRepository, dealNotes);
            #endregion

            var             notesRepository     = new Mock <INotesRepository>();
            var             httpRequest         = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPPOST), $"{AppSettings.BASEURL}{RouteHelper.NotesRoutePrefix}");
            NotesController dealNotesController = CreateDealNotesController(httpRequest, notesRepository.Object);

            //Build response
            IList <Data.Models.grs_VGrsNote> dealDbData = new List <Data.Models.grs_VGrsNote>
            {
                new Data.Models.grs_VGrsNote
                {
                    Dealnum    = 101,
                    Notenum    = 100,
                    Notetype   = 3,
                    Notes      = "Test Notes Desc",
                    Notedate   = Convert.ToDateTime("03/01/2019"),
                    Whoentered = 8069,
                    Name       = "Chris Downey",
                    FirstName  = "Chris",
                    MiddleName = null,
                    LastName   = "Downey"
                }
            };

            notesRepository.Setup(p => p.GetNotebyNoteNumber(0)).Returns(dealDbData);

            #region Act

            var response = dealNotesController.Post(dealNotes);
            #endregion

            #region Expected Data

            var expectedDealNote = new Notes()
            {
                DealNumber = 101,
                Notenum    = 100,
                Notetype   = 3,
                NoteText   = "Test Notes Desc",
                Notedate   = Convert.ToDateTime("03/01/2019"),
                Whoentered = 8069,
                Name       = "Chris Downey",
                FirstName  = "Chris",
                MiddleName = null,
                LastName   = "Downey"
            };

            #endregion

            #region Assert
            var contentResult = response as NegotiatedContentResult <ResponseItem <Notes> >;

            Assertions.AssertCreatedResponse(contentResult);
            var dealNoteData = contentResult.Content.data;

            //Data
            var actualDealNote = dealNoteData;

            Assertions.AssertData(expectedDealNote, actualDealNote);

            //Links & Messages
            //  Assert.IsEmpty(contentResult.Content.links);
            Assert.IsEmpty(contentResult.Content.messages);
            #endregion
        }