public void CreateNewMultiHint() { // Arrange var importer = new ExerciseImportHelper(); const string validHeader = "ExerciseCode,Name,CDT_Class,CDT_AtHome,IsMovementDataCo" + "llected,UnitTarget,HintEasier,HintHarder,Hint1,Hint2,Hint3,MDT_Class," + "MDT_AtHome,OldCode,Name_animationFile," + "Old_Name_animationFile"; string inputLine = "JUMP_999_B,Standing backflip,Y,Y,N,Y,land on your back," + "double backflip," + "Push off with both feet. ,Use your muscles! ,Try harder! , " + "N,N,,STAB_012_X_StandingWeightShift,STAB_012 Standing weight shift"; string input = validHeader + Environment.NewLine + inputLine; // Act var result = importer.ImportWithoutDelete(input, _existingExercises); // Assert List <Exercise> resultList = result.ToList(); resultList[4].ExerciseCode.Should().Be("JUMP_999_B"); resultList[4].Name.Should().Be("Standing backflip"); resultList[4].HasRepetitionTarget.Should().Be(true); resultList[4].EasierHint.Should().Be("land on your back"); resultList[4].HarderHint.Should().Be("double backflip"); var hintList = (from h in resultList[4].ExerciseHints select h.Text).ToList(); hintList[0].Should().Be("Push off with both feet."); hintList[1].Should().Be("Use your muscles!"); hintList[2].Should().Be("Try harder!"); resultList.Count().Should().Be(5); }
public void UpdateExisting() { // Arrange var processor = new CSVProcessorMock(); var importer = new ExerciseImportHelper(processor); const string validHeader = "ExerciseCode,Name,CDT_Class,CDT_AtHome,IsMovementDataCo" + "llected,UnitTarget,HintEasier,HintHarder,Hint1,Hint2,MDT_Class," + "MDT_AtHome,OldCode,Name_animationFile," + "Old_Name_animationFile"; string inputLine = "STAB_012_X,TestName,Y,Y,N,Y,make it easy," + "make it hard," + "Stand with your feet hip width apart and keep your legs straight as you shift weight from one foot to the other. ," + ",N,N,,STAB_012_X_StandingWeightShift,STAB_012 Standing weight shift"; string input = validHeader + Environment.NewLine + inputLine; var originalId = _existingExercises.ToList()[2].Id; // Act var result = importer.ImportWithoutDelete(input, _existingExercises); // Assert List <Exercise> resultList = result.ToList(); resultList[2].Name.Should().Be("TestName"); resultList[2].ExerciseCode.Should().Be("STAB_012_X"); resultList[2].HasRepetitionTarget.Should().Be(true); resultList[2].EasierHint.Should().Be("make it easy"); resultList[2].HarderHint.Should().Be("make it hard"); resultList[2].Id.Should().Be(originalId); resultList.Count().Should().Be(4); }
public void SplitLineWithTwoHints() { // Arrange var input = GoodHeader2Hints + Environment.NewLine + inputTextWithCommaInHint; var expectedExercise = new Exercise { ExerciseCode = "FLX_003_L", Name = "Old Calf stretch Left", EasierHint = "Easy, Partner", HarderHint = "As a diamond." }; ExerciseImportHelper importer = new ExerciseImportHelper(); // Act var result = importer.ImportWithoutDelete(input, new HashSet <Exercise>()); // Assert var resultEx = result.ToList()[0]; resultEx.ExerciseCode.Should().Be(expectedExercise.ExerciseCode); resultEx.Name.Should().Be(expectedExercise.Name); resultEx.EasierHint.Should().Be(expectedExercise.EasierHint); resultEx.HarderHint.Should().Be(expectedExercise.HarderHint); resultEx.ExerciseHints.Count().Should().Be(2); resultEx.ExerciseHints.Should().Contain(c => c.Text == "Knees Straight"); resultEx.ExerciseHints.Should().Contain(c => c.Text == "Heels on the floor"); }
public void ThrowExceptionWhenNoDataIsThere() { const string CSVListTest3 = "ExerciseCode,Name,CDT_Class,CDT" + "_AtHome,IsMovementDataCollected,UnitTarget," + "HintEasier,Hint Harder,Hint1,Hint2,MDT_Class,MDT_AtHome,OldCode," + "Name_animationFile,Old_Name_animationFile"; // Arrange var Import = new ExerciseImportHelper(); var AllExList = new List <string[]>(); // Act Action act1 = () => Import.ImportWithoutDelete(CSVListTest3, new List <Exercise>()); Action act2 = () => Import.ImportWithDelete(CSVListTest3, new List <Exercise>()); // Assert act1.Should().Throw <ArgumentException>(); act2.Should().Throw <ArgumentException>(); }
public void IgnoreBlankLines() { const string CSVListTest2 = "ExerciseCode,Name,CDT_Class,CDT" + "_AtHome,IsMovementDataCollected,UnitTarget," + "HintEasier,HintHarder,Hint1,Hint2,MDT_Class,MDT_AtHome,OldCode," + "Name_animationFile,Old_Name_animationFile\r\n" + ",,,,,,,,,,,,,,\r\nFLX_003_L,Old Calf stretch Left,Y,n,y,n,\"Easy, Partner" + "\",As a diamond.,,,,,,,,,,, \r\n,,,,,,,,,,,,,,\r\n" + "FLX_003_R,Old Calf stretch Right,Y,n,y,n,\"Easy, Partner\",As a diamond" + ".,,,,,,,,,,,\r\n,,,,,,,,,,,,,,\r\n" + "STAB_012_X,Standing weight shift,Y,n,y,n,Don't move,Close your eyes,,,," + ",,,,,,,\r\nKSA_999_X,One Finger pull-up,Y,n,y,n,Use two fingers,Pinky Fin" + "ger,,,,,,,,,,,"; // Arrange var importer = new ExerciseImportHelper(); // Act var allExList = importer.ImportWithoutDelete(CSVListTest2, new List <Exercise>()); // Assert allExList.Count().Should().Be(4); }