public void NoDataOnServer_CorrectData()
        {
            data.Products = new [] { new ProductData()
                                     {
                                         Id = new Guid(), MeasureUnitCode = measurecode, Name = productName, Price = 10
                                     } };
            dataSerialized = JsonConvert.SerializeObject(data);
            A.CallTo(() => productsReference.FindCodeByName(productName)).Returns(0);
            A.CallTo(() => measureUnitsReference.FindByCode(measurecode)).Returns(new MeasureUnit());
            var provider = new ProviderProcessor(productsReference, measureUnitsReference, repository);

            //provider.ProcessProviderData(dataSerialized);
            Approvals.Verify(provider.ProcessProviderData(dataSerialized));
        }
        public void SetUp()
        {
            providerRepository = A.Fake <IRepository>();
            providerData       = new ProviderData
            {
                Id         = Guid.Parse("666f730d-876b-42e4-a59b-254aba887f9d"),
                ProviderId = Guid.Parse("268798db-72c9-4246-98bb-6be06d88090c"),
                Products   = new ProductData[0],
                Timestamp  = DateTime.FromFileTimeUtc(1576674756L)
            };
            A.CallTo(() => providerRepository.FindByProviderId(Guid.Empty))
            .WithAnyArguments()
            .Returns(providerData);
            A.CallTo(() => providerRepository.RemoveById(Guid.Empty))
            .WithAnyArguments();
            A.CallTo(() => providerRepository.Save(providerData))
            .WithAnyArguments();
            A.CallTo(() => providerRepository.Update(providerData))
            .WithAnyArguments();

            productsReference = A.Fake <IProductsReference>();
            A.CallTo(() => productsReference.FindCodeByName(""))
            .WithAnyArguments()
            .Returns(null);

            productsReferenceBuilder = A.Fake <IProductsReferenceBuilder>();
            A.CallTo(() => productsReferenceBuilder.GetInstance())
            .Returns(productsReference);

            measureUnitsReference = A.Fake <IMeasureUnitsReference>();
            A.CallTo(() => measureUnitsReference.FindByCode(null))
            .WithAnyArguments()
            .Returns(null);
            measureUnitsReferenceBuilder = A.Fake <IMeasureUnitsReferenceBuilder>();
            A.CallTo(() => measureUnitsReferenceBuilder.GetInstance())
            .Returns(measureUnitsReference);
            A.CallTo(() => productsReference.FindCodeByName("Banana"))
            .Returns(42);
            A.CallTo(() => measureUnitsReference.FindByCode("u"))
            .Returns(new MeasureUnit());

            goodProduct = new ProductData
            {
                Id = Guid.Parse("4279c077-b7fb-4aed-bf35-5794ab327ce7"),
                MeasureUnitCode = "u",
                Name            = "Banana",
                Price           = 10.000m
            };

            productWithInvalidName = new ProductData
            {
                Id = Guid.Parse("4279c077-b7fb-4aed-bf35-5794ab327ce7"),
                MeasureUnitCode = "u",
                Name            = "Apple",
                Price           = 10.000m
            };

            productWithInvalidMeasureUnit = new ProductData
            {
                Id = Guid.Parse("4279c077-b7fb-4aed-bf35-5794ab327ce7"),
                MeasureUnitCode = "m",
                Name            = "Banana",
                Price           = 10.000m
            };

            productWithInvalidPrice = new ProductData
            {
                Id = Guid.Parse("4279c077-b7fb-4aed-bf35-5794ab327ce7"),
                MeasureUnitCode = "u",
                Name            = "Banana",
                Price           = -10.000m
            };

            products = new Dictionary <string, ProductData>
            {
                { "good", goodProduct },
                { "name", productWithInvalidName },
                { "unit", productWithInvalidMeasureUnit },
                { "price", productWithInvalidPrice }
            };

            providerProcessor = new ProviderProcessor(providerRepository,
                                                      productsReferenceBuilder,
                                                      measureUnitsReferenceBuilder,
                                                      new ProductValidator(productsReferenceBuilder, measureUnitsReferenceBuilder));
        }
        public void NoDataOnServer_NoProductData()
        {
            var provider = new ProviderProcessor(productsReference, measureUnitsReference, repository);

            Approvals.Verify(provider.ProcessProviderData(dataSerialized));
        }