public void Should_Throw_If_Records_Are_Null()
            {
                // Given
                var fixture = new CsvHelpersFixture(peopleExists: false);

                // When
                var result = Record.Exception(() => fixture.WriteWithMapping());

                // Then
                result.ShouldBeType <ArgumentNullException>().ParamName.ShouldEqual("records");
            }
            public void Should_Throw_If_Mapping_Is_Null()
            {
                // Given
                var fixture = new CsvHelpersFixture();

                fixture.DictionaryMap = null;
                // When
                var result = Record.Exception(() => fixture.WriteWithMapping(true));

                // Then
                result.ShouldBeType <ArgumentNullException>().ParamName.ShouldEqual("mapping");
            }
            public void Should_Throw_If_Settings_Are_Null()
            {
                // Given
                var fixture = new CsvHelpersFixture();

                fixture.Settings = null;

                // When
                var result = Record.Exception(() => fixture.WriteWithMapping());

                // Then
                result.ShouldBeType <ArgumentNullException>().ParamName.ShouldEqual("settings");
            }
            public void Should_Throw_If_CsvFile_Is_Null()
            {
                // Given
                var fixture = new CsvHelpersFixture(false);

                fixture.ResultPath = null;

                // When
                var result = Record.Exception(() => fixture.WriteWithMapping());

                // Then
                result.ShouldBeType <ArgumentNullException>().ParamName.ShouldEqual("csvFile");
            }
            public void Should_Write_Records_To_CsvFile_With_Dictionary_Map()
            {
                // Given
                var fixture = new CsvHelpersFixture(false);

                // When
                fixture.WriteWithMapping();

                // Then
                var resultFile = fixture.FileSystem.GetFile(fixture.ResultPath);

                resultFile.Exists.ShouldEqual(true);
                string resultString;

                using (var resultStream = resultFile.OpenRead())
                    using (var streamReader = new StreamReader(resultStream, Encoding.UTF8)) {
                        resultString = streamReader.ReadToEnd();
                    }
                resultString.Trim().ShouldEqual(Resources.CsvHelper_MappedFile.Trim());
            }