public void ShouldCreateAttributes() { List <MpAttribute> inputList = new List <MpAttribute>() { new MpAttribute() { AttributeId = 0, Name = "Existing Attribute 1", CategoryId = 2, Category = "Category #1", AttributeTypeId = 3, AttributeTypeName = "AttributeType #1", PreventMultipleSelection = false }, new MpAttribute() { AttributeId = 0, Name = "New Attribute 1", CategoryId = 2, Category = "Category #1", AttributeTypeId = 3, AttributeTypeName = "AttributeType #1", PreventMultipleSelection = false }, new MpAttribute() { AttributeId = 0, Name = "Existing Attribute 2", CategoryId = 3, Category = "Category #2", AttributeTypeId = 3, AttributeTypeName = "AttributeType #1", PreventMultipleSelection = false } }; _mpApiUserRepository.Setup(mocked => mocked.GetToken()).Returns("yeah!"); _mpRestRepository.Setup(mocked => mocked.UsingAuthenticationToken("yeah!")).Returns(_mpRestRepository.Object); _mpRestRepository.Setup(mocked => mocked.Search <MpRestAttribute>(It.IsAny <string>(), It.IsAny <string>(), (string)null, false)).Returns( new List <MpRestAttribute>() { new MpRestAttribute() { AttributeId = 1, Name = "Existing Attribute 1", CategoryId = 2, AttributeTypeId = 3, }, new MpRestAttribute() { AttributeId = 2, Name = "Existing Attribute 2", CategoryId = 3, AttributeTypeId = 3 } }); _mpAttributeRepository.Setup(mocked => mocked.CreateAttribute(It.IsAny <MpAttribute>())).Returns(3); var result = _fixture.CreateMissingAttributes(inputList, 3); _mpAttributeRepository.VerifyAll(); Assert.IsNotNull(result); Assert.AreEqual(result.Count, 3, "Result count should match what was passed in"); Assert.AreEqual(result.Count(attribute => attribute.AttributeId == 0), 0, "All attributes should have an id that does not equal zero"); }