बनाते समय आप एक विशिष्ट कन्स्ट्रक्टर तर्क मान का उपयोग करने के लिए ढांचे को कैसे बताते हैं, मैं मशीन को बताना चाहता हूं। विषय बनाने के दौरान एक रचनात्मक तर्क के लिए विशिष्ट मान का उपयोग करने के लिए फ्रेमवर्क बनाता हैमशीन का उपयोग करना। फ्लेक्स और विद सब्जेक्ट <TSubject> विषय
परीक्षण के अंतर्गत विषय निम्नलिखित निर्माता
/// <summary>
/// Initializes a new instance of the <see cref="CsvFileRepository{TModel}"/> class.
/// </summary>
/// <param name="fileService">The file service.</param>
/// <param name="repositorySettings">The repository settings.</param>
/// <param name="mappingFunction">The mapping function. The mapping function takes in a line from the CSV file and returns the model for said line.</param>
public CsvFileRepository(IFileService fileService, IRepositorySettings repositorySettings, Func<string, TModel> mappingFunction)
{
this.FileService = fileService;
this.RepositorySettings = repositorySettings;
this.MappingFunction = mappingFunction;
}
मैं एक परीक्षण के ठूंठ बना लिया है इस प्रकार है:
public class when_i_pass_a_csv_file_the_results_are_mapped_to_model_objects : WithSubject<CsvFileRepository<StandardOffer>>
{
Establish context =() => With(new OffersInFile(new[] { OfferTestData.BobsCsvTestData, OfferTestData.JohnsCsvTestData }));
Because of =() => result = Subject.Get();
It should_return_the_same_number_of_fruits_as_there_are_in_the_source_repository =() => result.Count().ShouldEqual(2);
static IEnumerable<IOffer> result;
}
लेकिन मुझे यकीन नहीं है कि मशीन को कैसे बताना है। फनक मैपिंग फ़ंक्शन तर्क के लिए एक विशिष्ट मान का उपयोग करने के लिए सक्षम है।