Ejemplo n.º 1
0
        public void Should_Not_Add_Anything()
        {
            // given
            var supply = new XmlMedicineSupplyModel
            {
                Medicines = new List <XmlMedicineModel>
                {
                    new XmlMedicineModel
                    {
                        IsNew       = true,
                        Category    = MedicineCategory.Normal,
                        PricePerOne = 8.50,
                        Quantity    = 100,
                        Refundation = 0.80,
                        Name        = "Aspiryna Light"
                    },
                    new XmlMedicineModel
                    {
                        StockId  = context.Medicines.First().ID,
                        Quantity = 100,
                    },
                    new XmlMedicineModel
                    {
                        IsNew       = false,
                        Category    = MedicineCategory.Special,
                        PricePerOne = 22.22,
                        Quantity    = 100,
                        Refundation = 0.80,
                        Name        = "Aspiryna MAX"
                    }
                }
            };
            var fileFormMock = new Mock <IFormFile>();

            fileFormMock.Setup(f => f.ContentType).Returns("text/xml");
            var fileCopyMock   = new Mock <ICopy>();
            var loggerMock     = new Mock <ILogger <GetXMLStoreUpdateUseCase> >();
            var serializerMock = new Mock <ISerializer <MemoryStream, XmlMedicineSupplyModel> >();

            serializerMock.Setup(s => s.Deserialize(It.IsAny <MemoryStream>())).Returns(supply);
            const int expectedStockMedsCount    = 1;
            const int expectedExternalMedsCount = 0;

            var useCase = new GetXMLStoreUpdateUseCase(
                context,
                loggerMock.Object,
                serializerMock.Object,
                fileCopyMock.Object);

            // when
            var result = useCase.Execute(fileFormMock.Object);
            var stockMedicinesCount   = context.Medicines.Count();
            var externalMedicineCount = context.ExternalDrugstoreMedicines.Count();

            // then
            Assert.AreEqual(false, result.Succes);
            Assert.AreEqual(stockMedicinesCount, expectedStockMedsCount);
            Assert.AreEqual(externalMedicineCount, expectedExternalMedsCount);
            Assert.IsTrue(context.Medicines.First().Name == "Lek testowy");
        }
 public StorekeeperController(
     GetXMLStoreUpdateUseCase getXMLStore,
     PostXMLStoreOrderListUseCase postXMLStore)
 {
     this.getXMLStore  = getXMLStore;
     this.postXMLStore = postXMLStore;
 }