Exemplo n.º 1
0
            public void ThrowCOMExceptionIfDeviceNotConnected([Greedy] ScanningDevice sut)
            {
                sut.IsConnected = false;

                sut.Invoking(x => x.GetImage(ScannerSettingsCustomization.SupportedImageFormat))
                .Should().Throw <COMException>();
                sut.Images.Should().BeEmpty();
            }
Exemplo n.º 2
0
            public void EmptyImagesCollection([Frozen] IList <byte[]> images, ScanningDevice sut)
            {
                sut.Images = images;
                sut.Images
                .Should().NotBeEmpty()
                .And.BeEquivalentTo(images);

                sut.ClearImages();

                sut.Images
                .Should().NotBeNull()
                .And.BeEmpty();
            }
Exemplo n.º 3
0
            public void RaiseIsImagingPropertyChanged([Greedy] ScanningDevice sut)
            {
                // IsImaging should only be true during the operation of GetImage()
                sut.IsImaging.Should().BeFalse();

                using (var monitoredSubject = sut.Monitor())
                {
                    monitoredSubject.Subject.GetImage(ScannerSettingsCustomization.SupportedImageFormat);

                    monitoredSubject.Should().RaisePropertyChangeFor(x => x.IsImaging);
                }

                sut.IsImaging.Should().BeFalse();
            }
Exemplo n.º 4
0
            public void ThrowIfDeviceInstanceExists(
                [Frozen] ImagingDeviceConfig deviceConfig,
                [Frozen] ScannerSettings settings,
                [Frozen, CollectionSize(1)] IEnumerable <ScannerSettings> _,
                [Greedy] ScanningDevices sut)
            {
                var existingInstance = new ScanningDevice(settings, deviceConfig);

                sut.Invoking(x => x.AddDevice(existingInstance))
                .Should().Throw <ArgumentException>();
                sut.Devices.Should()
                .HaveCount(1)
                .And.OnlyHaveUniqueItems()
                .And.Contain(i => i.DeviceID == existingInstance.DeviceID);
            }
Exemplo n.º 5
0
            public void ContainUniqueDevices(
                ScanningDevice device,
                [Frozen] ImagingDeviceConfig deviceConfig,
                [Frozen, CollectionSize(5)] IEnumerable <ScannerSettings> scannerSettings,
                [Greedy] ScanningDevices sut)
            {
                var scanningDevices = scannerSettings.Select(x => new ScanningDevice(x, deviceConfig));

                sut.AddDevice(device);

                sut.Devices.Should()
                .HaveCount(6)
                .And.OnlyHaveUniqueItems()
                .And.Contain(scanningDevices)
                .And.Contain(i => i.DeviceID == device.DeviceID);
            }
Exemplo n.º 6
0
 public void ThrowIfImageFormatNotSupported([Greedy] ScanningDevice sut)
 {
     sut.Invoking(x => x.GetImage(IImagingDevice.ImageFormat.Gif))
     .Should().Throw <ArgumentException>();
     sut.Images.Should().BeEmpty();
 }
Exemplo n.º 7
0
            public void ReturnImagesForSupportedFormat([Frozen] IEnumerable <byte[]> images, [Greedy] ScanningDevice sut)
            {
                sut.GetImage(ScannerSettingsCustomization.SupportedImageFormat);

                sut.Images.Count.Should().Be(images.Count());

                foreach (var(image, deviceImage) in Enumerable.Zip(images, sut.Images))
                {
                    // Image data won't match exactly because headers will differ due to conversion
                    image.Should().IntersectWith(deviceImage);
                }
            }
Exemplo n.º 8
0
 public void InitializeAllPropertiesGreedy([Greedy] ScanningDevice sut)
 {
     sut.AssertAllPropertiesAreNotDefault();
     sut.IsConnected.Should().BeTrue();
     sut.IsImaging.Should().BeFalse();
 }
Exemplo n.º 9
0
            public void EqualSettingsHash([Frozen] ScannerSettings settings, ScanningDevice sut)
            {
                var result = sut.GetHashCode();

                result.Should().Be(settings.Id.GetHashCode());
            }
Exemplo n.º 10
0
 public void BeEquivalentToClone([Frozen] ScannerSettings _, ScanningDevice sut, ScanningDevice clone)
 => sut.Equals(clone).Should().BeTrue();