示例#1
0
        public async Task AddContactsToList_BadRequest_ListDoesntExist()
        {
            //Arange
            int validContactId        = 1;
            int listIdThatDoesntExist = 10;

            var model = new ContactListDTO()
            {
                ContactIds = new List <int>()
                {
                    validContactId
                },
                ListIds = new List <int>()
                {
                    listIdThatDoesntExist
                }
            };

            //Act
            var controller   = new ContactController(_serviceBusMock.Object, _contactContext.Object);
            var actionResult = await controller.AddContactsToLists(model);

            //Assert
            var result = Assert.IsType <BadRequestResult>(actionResult);

            Assert.Equal((int)System.Net.HttpStatusCode.BadRequest, result.StatusCode);
        }
示例#2
0
        public async Task AddContactsToList_Ok()
        {
            //Arange
            int validContactId = 1;
            int validListId    = 2;

            var model = new ContactListDTO()
            {
                ContactIds = new List <int>()
                {
                    validContactId
                },
                ListIds = new List <int>()
                {
                    validListId
                }
            };

            //Act
            var controller   = new ContactController(_serviceBusMock.Object, _contactContext.Object);
            var actionResult = await controller.AddContactsToLists(model);

            //Assert
            var result = Assert.IsType <OkResult>(actionResult);

            Assert.Equal((int)System.Net.HttpStatusCode.OK, result.StatusCode);
        }
示例#3
0
        public async Task AddContactsToList_BadRequest_ModelNotValid()
        {
            //Arange
            var model = new ContactListDTO();

            //Act
            var controller   = new ContactController(_serviceBusMock.Object, _contactContext.Object);
            var actionResult = await controller.AddContactsToLists(model);

            //Assert
            var result = Assert.IsType <BadRequestObjectResult>(actionResult);

            Assert.Equal((int)System.Net.HttpStatusCode.BadRequest, result.StatusCode);
            Assert.IsType <SerializableError>(result.Value);
        }