コード例 #1
0
        public async Task Post_ReceivesUnknownId_ReturnsNotFound()
        {
            // Arrange
            _contactRepository.GetContactById(1).Returns(NullContact.GetInstance());
            var controller = CreateController();

            // Act
            var actionResult = await controller.Details(new ContactUpdateViewModel { Id = 1 });

            // Assert
            actionResult.Should().BeOfType <NotFoundResult>();
        }
コード例 #2
0
        public void Get_CannotFindContact_ReturnsNotFound()
        {
            // Arrange
            _contactRepository.GetContactById(1).Returns(NullContact.GetInstance());
            var controller = CreateController();

            // Act
            var actionResult = controller.Details(1);

            // Assert
            actionResult.Should().BeOfType <NotFoundResult>();
        }
コード例 #3
0
        public async Task UnknownId_ReturnsNotFound()
        {
            // Arrange
            _contactRepository.GetContactById(1).Returns(NullContact.GetInstance());
            var controller = CreateController();

            // Act
            var actionResult = await controller.Favorite(1);

            // Assert
            actionResult.Should().BeOfType <NotFoundResult>();
        }
コード例 #4
0
ファイル: AddTests.cs プロジェクト: n-develop/peopleiknow
        public async Task Post_ContactCouldNotBeCreated_ReturnsBadRequest()
        {
            // Arrange
            _contactRepository.AddContact(Arg.Any <Contact>()).Returns(NullContact.GetInstance());
            var controller = CreateController();

            // Act
            var actionResult = await controller.Add(new Contact());

            // Assert
            actionResult.Should().BeOfType <BadRequestResult>();
        }
コード例 #5
0
        public Contact GetContactById(int id)
        {
            var contact = _context.Contacts
                          .Include(c => c.EmailAddresses)
                          .Include(c => c.TelephoneNumbers)
                          .Include(c => c.Relationships)
                          .Include(c => c.StatusUpdates)
                          .Include(c => c.Activities)
                          .Include(c => c.Gifts)
                          .Include(c => c.Reminders)
                          .FirstOrDefault(c => c.Id == id);

            return(contact ?? NullContact.GetInstance());
        }