public async void StoreItemsInCache_StoresAllItemsInTheCache() { // Arrange var mockProvider = new MockProvider(); var dicomdirParser = mockProvider.GetDicomdirFileParserFake(); dicomdirParser.ParseDicomdirAsync(Arg.Any<string>()).Returns(Task.FromResult(GetDicomdirInfosFake())); var cacheProvider = mockProvider.GetCacheProviderFake(); var cacheIndexProvider = mockProvider.GetCacheIndexProviderFake(); cacheIndexProvider.GetCacheIndex(Arg.Any<object>()).Returns(c => c.Arg<object>().GetType().Name); var dicomdirFileCacheStoreProvider = new DicomdirFileCacheStoreProvider(dicomdirParser, cacheProvider, cacheIndexProvider); // Act var result = await dicomdirFileCacheStoreProvider.StoreItemsInCache(""); var patient = result.Patients.Single(); var study = result.Studies.Single(); var series = result.Series.First(); // Assert Assert.That(patient.PatientName.ToString(), Is.EqualTo("John Doe")); Assert.That(patient.PatientID.StringRepresentationWithoutSlash, Is.EqualTo("9107256444")); Assert.That(study.StudyInstanceUID.StringRepresentation, Is.EqualTo("1.2")); Assert.That(series.StudyInstanceUID.StringRepresentation, Is.EqualTo("1.2")); Assert.That(series.SeriesInstanceUID.StringRepresentation, Is.EqualTo("1.3")); Assert.That(() => cacheProvider.Received(1).Store("PatientInfo", Arg.Any<object>(), true), Throws.Nothing); Assert.That(() => cacheProvider.Received(1).Store("StudyInfo", Arg.Any<object>(), true), Throws.Nothing); Assert.That(() => cacheProvider.Received(2).Store("SeriesInfo", Arg.Any<object>(), true), Throws.Nothing); }
public void LoadDataFromServer_GetResponse_StoresInCache() { // Arrange var mockProvider = new MockProvider(); var cacheProvider = mockProvider.GetCacheProviderFake(); var dataLoader = new DicomDataLoader<TestInfo>(cacheProvider, mockProvider.GetCacheIndexProviderFake(), mockProvider.GetDicomClientFactoryFake(), mockProvider.GetDicomRequestFactoryFake()); var whereCollection = mockProvider.GetWhereCollection(); whereCollection.WhereEquals(DicomTags.PatientID, 1); // Act var result = dataLoader.LoadDataFromServer(whereCollection); // Assert Assert.That(result.Count, Is.EqualTo(1)); Assert.That(result.All(c => c.PatientID == 1), Is.True); Assert.That(() => cacheProvider.Received(1).Store(Arg.Any<string>(), Arg.Any<object>(), Arg.Any<bool>()), Throws.Nothing); }
public void LoadDataFromServer_WhereCollection_CreatesRequest() { // Arrange var mockProvider = new MockProvider(); var requestFactory = new DicomRequestFactoryFake(); var dataLoader = new DicomDataLoader<TestInfo>(mockProvider.GetCacheProviderFake(), mockProvider.GetCacheIndexProviderFake(), mockProvider.GetDicomClientFactoryFake(), requestFactory); var whereCollection = new WhereCollection<TestInfo>(mockProvider.GetDicomMappingFake()); whereCollection.WhereEquals(DicomTags.PatientID, 1); // Act dataLoader.LoadDataFromServer(whereCollection); var whereItem = ((IDicomWhereCollection)requestFactory.WhereCollection).Single(); // Assert Assert.That(whereItem.DicomTag, Is.EqualTo(DicomTags.PatientID)); Assert.That(whereItem.Value, Is.EqualTo("1")); }
public void LoadDataFromServer_AllCombinationsAreAddedAsRequest() { // Arrange var mockProvider = new MockProvider(); var dicomClientFactory = mockProvider.GetDicomClientFactoryFake(); var dicomClient = mockProvider.GetDicomClientFake(); var dataLoader = new DicomDataLoader<TestInfo>(mockProvider.GetCacheProviderFake(), mockProvider.GetCacheIndexProviderFake(), dicomClientFactory, mockProvider.GetDicomRequestFactoryFake()); dicomClientFactory.CreateDicomClient().Returns(dicomClient); var whereCollection = mockProvider.GetWhereCollection(); whereCollection.WhereEquals(DicomTags.PatientID, 1); whereCollection.WhereEquals(DicomTags.PatientID, 2); whereCollection.WhereEquals(DicomTags.PatientName, "test"); whereCollection.WhereLike(DicomTags.PatientName, "test1"); // Act dataLoader.LoadDataFromServer(whereCollection); // Assert Assert.That(() => dicomClient.Received(4).AddFindRequest(Arg.Any<IDicomFindRequest<TestInfo>>()), Throws.Nothing); }
public async void LoadDataFromCacheAsync_ReturnsFromCache() { // Arrange var mockProvider = new MockProvider(); var cacheProvider = mockProvider.GetCacheProviderFake(); var dataLoader = new DicomDataLoader<TestInfo>(cacheProvider, mockProvider.GetCacheIndexProviderFake(), mockProvider.GetDicomClientFactoryFake(), mockProvider.GetDicomRequestFactoryFake()); var whereCollection = new WhereCollection<TestInfo>(mockProvider.GetDicomMappingFake()); whereCollection.WhereEquals(DicomTags.PatientID, 1); // Act var result = (await dataLoader.LoadDataFromCacheAsync(whereCollection)).Single(); // Assert Assert.That(result.PatientID, Is.EqualTo(1)); Assert.That(() => cacheProvider.Received(1).Retrieve<TestInfo>(), Throws.Nothing); }