public void GetMatchingHeader_ReturnsNull_WhenNotFound() { // Arrange var headers = new List <string> { "id", "first_name", "last_name", "version", "insurance_company" }; var property = PropertyInfoTestHelpers.GetTestProperties().First(prop => prop.Name == "UserId"); // Act var result = _sut.GetMatchingHeader(headers, property); // Assert Assert.IsNull(result); }
public void GetMatchingHeader_ReturnsExpectedHeader_WhenFound() { // Arrange var userId = "user_id"; var headers = new List <string> { userId, "first_name", "last_name", "version", "insurance_company" }; var property = PropertyInfoTestHelpers.GetTestProperties().First(prop => prop.Name == "UserId"); // Act var result = _sut.GetMatchingHeader(headers, property); // Assert Assert.AreEqual(userId, result); }
public void ParseRows_ReturnsTwoEnrollments_WhenGivenTwoLines() { // Arrange var strProp = fixture.Create <string>(); var intProp = fixture.Create <int>(); var indexes = PropertyInfoTestHelpers.GetTestIndexs(); var rows = new List <string> { $"{strProp},{intProp}", $"{strProp}.1,{intProp + 1}" }; // Act var response = _sut.ParseRows(indexes, rows); // Assert Assert.AreEqual(2, response.Count()); }
public void ParseRow_ReturnsIntPropertyAndStringProperty() { // Arrange var strProp = fixture.Create <string>(); var intProp = fixture.Create <int>(); var indexes = PropertyInfoTestHelpers.GetTestIndexs(); var rows = new List <string> { strProp, intProp.ToString() }; // Act var response = _sut.ParseRow(indexes, rows); // Assert Assert.AreEqual(strProp, response.UserId); Assert.AreEqual(intProp, response.Version); }
public void GetEnrollments_CallsCorrectServicesAndReturnsEnrollments() { // Arrange var indexes = PropertyInfoTestHelpers.GetTestIndexs(); var rows = fixture.CreateMany <string>(3).ToList(); var enrollments = fixture.CreateMany <Enrollment>(3); _csvServiceMock.Setup(s => s.ParseRows(It.IsAny <Dictionary <PropertyInfo, int> >(), It.IsAny <List <string> >())).Returns(enrollments); _enrollmentServiceMock.Setup(x => x.GetEnrollmentOutput(It.IsAny <IEnumerable <Enrollment> >())).Returns(enrollments); // Act var result = _sut.GetEnrollments(indexes, rows); // Assert _csvServiceMock.Verify(s => s.ParseRows(It.Is <Dictionary <PropertyInfo, int> >(x => x == indexes), It.Is <List <string> >(x => x == rows)), Times.Once); _enrollmentServiceMock.Verify(s => s.GetEnrollmentOutput(It.IsAny <IEnumerable <Enrollment> >()), Times.Once); Assert.AreEqual(3, result.Count()); }
public void GetHeaderRow_ReturnsHeaderRow_WhenIsHeaderRow() { // Arrange var enrollmentRows = fixture.CreateMany <string>(3).ToList(); var headers = fixture.CreateMany <string>(3).ToList(); var properties = PropertyInfoTestHelpers.GetTestProperties(); _csvServiceMock.Setup(s => s.GetAssumedHeaderRow(It.IsAny <List <string> >())).Returns(headers); _csvServiceMock.Setup(s => s.IsHeaderRow(It.IsAny <List <string> >())).Returns(true); _enrollmentServiceMock.Setup(s => s.GetEnrollmentProperties()).Returns(properties); // Act var result = _sut.GetHeaderRow(enrollmentRows); // Assert _csvServiceMock.Verify(s => s.GetAssumedHeaderRow(It.Is <List <string> >(x => x == enrollmentRows)), Times.Once); _csvServiceMock.Verify(s => s.IsHeaderRow(It.Is <List <string> >(x => x == headers)), Times.Once); _enrollmentServiceMock.Verify(s => s.GetEnrollmentProperties(), Times.Once); _userFeedbackServiceMock.Verify(s => s.HeaderCountNotSameAsPropertyCount(It.Is <int>(x => x == 3), It.Is <int>(x => x == 5))); Assert.AreEqual(headers, result); }