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); }