private BcrReader CreateReader(
            IEnumerable <CostCentre> allCostCentres,
            IFile <Bcr> bcrCache,
            IUnit4Engine engine,
            bool updateCache = false)
        {
            var factory = new Mock <IUnit4EngineFactory>();

            factory.Setup(x => x.Create()).Returns(engine);

            var costCentresProvider = new Mock <ICostCentresProvider>();
            var costCentres         = new SerializableCostCentreList()
            {
                CostCentres = allCostCentres
            };

            costCentresProvider.Setup(x => x.GetCostCentres()).Returns(costCentres);

            return(new BcrReader(
                       Mock.Of <ILogging>(),
                       new BcrOptions(
                           Enumerable.Empty <string>(),
                           Enumerable.Empty <string>(),
                           Enumerable.Empty <string>(),
                           Enumerable.Empty <string>(),
                           Enumerable.Empty <string>(),
                           null,
                           updateCache),
                       bcrCache,
                       Mock.Of <IFile <SerializableCostCentreList> >(),
                       factory.Object,
                       costCentresProvider.Object));
        }
Beispiel #2
0
        public void CanSerializeThenDeserializeType()
        {
            var obj = new SerializableCostCentreList()
            {
                CostCentres = new CostCentre[0]
            };

            var json = JsonConvert.SerializeObject(obj);

            Assert.That(() => JsonConvert.DeserializeObject <SerializableCostCentreList>(json), Throws.Nothing);
        }