예제 #1
0
        public static NullContact GetInstance()
        {
            if (_instance == null)
            {
                _instance = new NullContact();
            }

            return(_instance);
        }
예제 #2
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>();
        }
예제 #3
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>();
        }
예제 #4
0
        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 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>();
        }
예제 #6
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());
        }