public ICollector GetOrAdd(ICollector collector)
        {
            var collectorToUse = _collectors.GetOrAdd(collector.Name, collector);

            if (!collector.LabelNames.SequenceEqual(collectorToUse.LabelNames))
                throw new InvalidOperationException("Collector with same name must have same label names");

            return collectorToUse;
        }
            public void SetUp_for_tests()
            {
                _collector= new Collector(new DatabaseContext());
                _testItem = new Item()
                {
                    ItemId = 1,
                    Name = "TestItem"
                };

            }
        public void SetupForTests()
        {
            _testCollector = new Collector(new DatabaseContext());

            _testItem = new Item() { ItemId = 100, Name = "TestItem", IsBought = true };
            _testIngredient = new Ingredient() { ItemId = 101, Name = "TestIngredient", Amount = 10 };
            _testRecipe = new Recipe() { RecipeId = 100, RecipeName = "TestOpskrift", Ingredients = new List<Ingredient>() { _testIngredient, new Ingredient() }, AddedTime = DateTime.Now };
            _testFoodplan = new Foodplan() { FoodPlanId = 100, CreatedDate = DateTime.Now, Recipies = new List<RecipesInFoodplan>() { new RecipesInFoodplan() {Recipe = _testRecipe, RecipeDate = DateTime.Now} }, FoodplanStartTime = DateTime.Now, FoodplanEndTime = DateTime.MaxValue, LastModified = DateTime.Now };
            _testShoppinglist = new Shoppinglist() { ShoppingListId = 100, Items = new List<Item>() { _testItem } };
            _testUser = new User() { UserId = 100, UserName = "Pete", UserPassword = "123", UserFoodplan = _testFoodplan, UserShoppingList = _testShoppinglist };
        }
        public JsonCodeWriter(CodeVariableReferenceExpression variable, ICollector collector)
        {
            if (variable == null)
                throw new ArgumentNullException("variable");

            if (collector == null)
                throw new ArgumentNullException("collector");

            _variable = variable;
            _collector = collector;
        }
        public void SetupForTests()
        {
            _testCollector = new Collector(new DatabaseContext());

            _testItem = new Item() {ItemId = 100, Name = "TestItem", IsBought = true};
            _testIngredient = new Ingredient() { ItemId = 101, Name = "TestIngredient", Amount = 10 };
            _testRecipe = new Recipe() {RecipeId = 100,RecipeName = "TestOpskrift", Ingredients = new List<Ingredient>() {_testIngredient, new Ingredient()} };
            _testFoodplan = new Foodplan() { FoodPlanId = 100, CreatedDate = DateTime.Now, RecipeList = new List<Recipe>() {_testRecipe} };
            _testShoppinglist = new Shoppinglist() {ShoppingListId = 100, ShoppingItems = new List<Item>() {_testItem} };
            _tesUser = new User() {UserId = 100,UserName = "Pete",UserPassword = "123",UserFoodplan = _testFoodplan, UserShoppinglist = _testShoppinglist};

        }
        public void SetUp_for_tests()
        {
            // Create mock for Unit of work
            mockData = Substitute.For<IDatabaseContext>();

            mockData.DbSetIngredients.Returns(inMemoryIngredients);
            
    

            _testCollector = new Collector(mockData);
            
            

        }
        public void GetReturnsProductWithSameId()
        {
            _mockCollector = Substitute.For<ICollector>();

            _controller = new ItemsController(_mockCollector);
            _controller.GetItem(1);
            _mockCollector.Items.GetWithId(1).Received();

            /*
            _mockCollector.Items.GetWithId(1).Returns(new Item() { IsBought = true, Name = "Abc", ItemId = 1 });
            Item returnItem = _controller.GetItem(1);
            Assert.That(returnItem.IsBought && returnItem.Name == "Abc" && returnItem.ItemId == 1);
            */
        }
            public ICollector Merge(ICollector coll)
            {
                if (!this.IsMergeable(coll))
                    throw new InvalidProgramException("Algorithmic error");

                IImageProvider ic = coll as IImageProvider;

                if (ic != null)
                {
                    List<string> Images = new List<string>(_ListImage);
                    Images.AddRange(ic.Image);
                    return new ImageCollector(Images);
                }

                return coll.Merge(this);
            }
            public ICollector Merge(ICollector coll)
            {
                if (!this.IsMergeable(coll))
                    throw new InvalidProgramException("Algorithmic error");

                IImageProvider mp = coll as IImageProvider;

                if (mp == null)
                    throw new InvalidProgramException("Algorithmic error");

                return Clone(mp.Image);
            }
            public bool IsMergeable(ICollector coll)
            {
                IImageProvider ic = coll as IImageProvider;

                if (ic != null)
                    return true;

                return coll.IsMergeable(this);
            }
 public bool IsMergeable(ICollector coll)
 {
     return false;
 }
 public ICollector Merge(ICollector coll)
 {
     throw new InvalidProgramException("Algorithmic error");
 }
            public bool IsMergeable(ICollector coll)
            {
                if (IsSealed)
                    return false;

                IImageProvider mp = coll as IImageProvider;

                return (mp != null);
            }
Example #14
0
		/**
		 * @param use visitor combinator that collects used entities.
		 * @param def visitor combinator that collects defined entities.
		*/
		public DefUse(ICollector use, ICollector def) : base(new Sequence(use,def))
		{
			this.use = use;
			this.def = def;
		}
 public bool Remove(ICollector collector)
 {
     ICollector dummy;
     return _collectors.TryRemove(collector.Name, out dummy);
 }
Example #16
0
 public void GetPayments(ICollector collector)
 {
     try
     {
         log.InfoFormat("Start collecting with collector {0}", collector.GetType());
         IList<Payment> payments = collector.GetPayments();
         log.InfoFormat("Finished collecting with collector {0}. {1} transactions collected.", collector.GetType(), payments.Count);
         AddPayments(payments);
     }
     catch (Exception ex)
     {
         log.Error(String.Format("error in collector {0}.", collector.GetType()), ex);
     }
 }
        public void SetUp()
        {
            target = new TestRunnerImpl();
            args = Stub<ITestRunnerArgs>();
            parser = Stub<IParser>();
            cleaner = Stub<ICleaner>();
            runDataBuilder = Stub<IRunDataBuilder>();
            runDataListBuilder = Stub<IRunDataListBuilder>();
            executorLauncher = Stub<IExecutorLauncher>();
            trxWriter = Stub<ITrxWriter>();
            breaker = Stub<IBreaker>();
            enumerator = Stub<IRunDataEnumerator>();
            windowsFileHelper = Stub<IWindowsFileHelper>();
            collector = Stub<ICollector>();

            target.Args = args;
            target.Parser = parser;
            target.Cleaner = cleaner;
            target.RunDataBuilder = runDataBuilder;
            target.RunDataListBuilder = runDataListBuilder;
            target.ExecutorLauncher = executorLauncher;
            target.TrxWriter = trxWriter;
            target.Breaker = breaker;
            target.Collector = collector;
            target.WindowsFileHelper = windowsFileHelper;
        }
Example #18
0
 internal virtual void Init(ICollector parent, LabelValues labelValues)
 {
     _labelValues = labelValues;
 }
 public void Register(ICollector collector)
 {
     if (!_collectors.TryAdd(collector.Name, collector))
         throw new InvalidOperationException(string.Format("A collector with name '{0}' has already been registered!", collector.Name));
 }
Example #20
-1
 public void SetUp_for_tests()
 {
     testItem = new Item
     {
         Name = "CorrectItem",
         IsBought = false
     };
     _collector = Substitute.For<ICollector>();
 }