public OpmVerificator(IIdentityManagement identityManagement, IEanEicCheckerHttpClient eanEicCheckerHttpClient, IOpmRepository opmRepository, IUserAccessService userAccessService) { IdentityManagement = identityManagement; EanEicCheckerHttpClient = eanEicCheckerHttpClient; OpmRepository = opmRepository; UserAccessService = userAccessService; }
public void SetUp() { Mock <IEanEicCheckerHttpClient> mockClient = new Mock <IEanEicCheckerHttpClient>(); //for "invalid" ean code returns invalid, ean ok otherwise mockClient.Setup(c => c.Post(It.IsAny <EanEicCode>())) .Returns( (EanEicCode code) => code.Code == "invalid" ? new CheckResult(CheckResultCode.EanInvalidCheckCharacter) : new CheckResult(CheckResultCode.EanOk)); EanEicCheckerHttpClient = mockClient.Object; OpmRepository = new OpmInMemoryRepository(); OpmRepoFiller.Fill(OpmRepository, PositiveTestData); IUserAccessService userAccessService = new UserAccessService(new UserAccessInMemoryRepository(), new TimeSpan(0, 1, 0), 999); IIdentityManagement identityManagement = new IdentityManagementMock(); IOpmVerificator opmVerificator = new OpmVerificator(identityManagement, mockClient.Object, OpmRepository, userAccessService); Controller = new OpmDuplicityController(opmVerificator, userAccessService) { Request = new HttpRequestMessage(), Configuration = new HttpConfiguration() }; }
public static void Fill(IOpmRepository repo) { using (StreamReader sr = new StreamReader(HttpContext.Current.Server.MapPath("Persistence/OpmRepoSampleData.csv"))) { string currentLine; while ((currentLine = sr.ReadLine()) != null) { repo.TryAdd(new Opm(new EanEicCode(currentLine))); } } }
public static void Fill(IOpmRepository repo, string path) { using (StreamReader sr = new StreamReader(path)) { string currentLine; while ((currentLine = sr.ReadLine()) != null) { if (!repo.TryAdd(new Opm(new EanEicCode(currentLine)))) { throw new Exception("Failed to add OPM [code= " + currentLine + "] to repository."); } } } }
public OpmVerificator(IIdentityManagement identityManagement, IEanEicCheckerHttpClient eanEicCheckerHttpClient, IOpmRepository opmRepository) { IdentityManagement = identityManagement; EanEicCheckerHttpClient = eanEicCheckerHttpClient; OpmRepository = opmRepository; }
public void Setup() { _repository = GetOpmRepository(); }