コード例 #1
0
        public void CommodityPool_FindBySymbolAndDetails_ReturnsAnnotatedCommodityIfExists()
        {
            TestCommodityPool commodityPool = new TestCommodityPool();
            string            symbol        = "symbol";
            string            wrongSymbol   = "dummy";
            Annotation        details       = new Annotation();

            Commodity          commodity          = commodityPool.Create(symbol);
            AnnotatedCommodity annotatedCommodity = commodityPool.Create(commodity, details) as AnnotatedCommodity;

            Assert.Equal(annotatedCommodity, commodityPool.Find(symbol, details));
            Assert.Null(commodityPool.Find(wrongSymbol));
        }
コード例 #2
0
        public void CommodityPool_FindBySymbol_ReturnsCommodityIfExists()
        {
            TestCommodityPool commodityPool = new TestCommodityPool();
            string            symbol        = "symbol";
            string            wrongSymbol   = "dummy";

            Commodity commodity = commodityPool.Create(symbol);

            Assert.Equal(commodity, commodityPool.Find(symbol));
            Assert.Null(commodityPool.Find(wrongSymbol));
        }
コード例 #3
0
        public void CommodityPool_CreateByCommodityAndDetails_CreatesCommodityAndAddsToPool()
        {
            TestCommodityPool commodityPool = new TestCommodityPool();
            string            symbol        = "symbol";
            Commodity         commodity     = commodityPool.Create(symbol);
            Annotation        details       = new Annotation();

            AnnotatedCommodity annotatedCommodity = commodityPool.Create(commodity, details) as AnnotatedCommodity;

            Assert.NotNull(annotatedCommodity);
            Assert.Equal(details, annotatedCommodity.Details);

            Assert.Equal(symbol, annotatedCommodity.BaseSymbol);
            Assert.Equal(symbol, annotatedCommodity.Symbol);
            Assert.Null(annotatedCommodity.QualifiedSymbol);

            Assert.True(commodityPool.Commodities.ContainsKey(symbol));
            Assert.Equal(commodity, commodityPool.Commodities[symbol]);

            Assert.True(commodityPool.AnnotatedCommodities.ContainsKey(new Tuple <string, Annotation>(symbol, details)));
            Assert.Equal(annotatedCommodity, commodityPool.AnnotatedCommodities[new Tuple <string, Annotation>(symbol, details)]);
        }
コード例 #4
0
        public void CommodityPool_CreateBySymbol_AddsQualifiedTextIfNeeded()
        {
            string symbol          = "sym&bol";
            string qualifiedSymbol = "\"" + symbol + "\"";

            TestCommodityPool commodityPool = new TestCommodityPool();

            Commodity commodity = commodityPool.Create(symbol);

            Assert.NotNull(commodity);
            Assert.Equal(symbol, commodity.BaseSymbol);
            Assert.Equal(qualifiedSymbol, commodity.Symbol);
            Assert.Equal(qualifiedSymbol, commodity.QualifiedSymbol);
        }
コード例 #5
0
        public void CommodityPool_CreateBySymbol_CreatesCommodityAndAddsToPool()
        {
            string            symbol        = "symbol";
            TestCommodityPool commodityPool = new TestCommodityPool();

            Commodity commodity = commodityPool.Create(symbol);

            Assert.NotNull(commodity);
            Assert.Equal(symbol, commodity.BaseSymbol);
            Assert.Equal(symbol, commodity.Symbol);
            Assert.Null(commodity.QualifiedSymbol);
            Assert.True(commodityPool.Commodities.ContainsKey(symbol));
            Assert.Equal(commodity, commodityPool.Commodities[symbol]);
            Assert.False(commodityPool.AnnotatedCommodities.Any());
        }
コード例 #6
0
        public void CommodityPool_FindOrCreateByCommodityAndDetails_CreatesAnnotatedCommodity()
        {
            TestCommodityPool commodityPool = new TestCommodityPool();
            string            symbol        = "symbol";
            Annotation        details       = new Annotation();
            Commodity         commodity     = commodityPool.Create(symbol);

            AnnotatedCommodity annotatedCommodity = commodityPool.FindOrCreate(commodity, details) as AnnotatedCommodity;

            Assert.NotNull(annotatedCommodity);
            Assert.Equal(details, annotatedCommodity.Details);

            AnnotatedCommodity annotatedCommodity2 = commodityPool.FindOrCreate(commodity, details) as AnnotatedCommodity;

            Assert.Equal(annotatedCommodity, annotatedCommodity2);
        }
コード例 #7
0
        public void CommodityPool_FindWithAnnotation_IgnoresAnnotationFlags()
        {
            TestCommodityPool  commodityPool      = new TestCommodityPool();
            string             symbol             = "symbol";
            Annotation         details            = new Annotation();
            Commodity          commodity          = commodityPool.Create(symbol);
            AnnotatedCommodity annotatedCommodity = commodityPool.FindOrCreate(commodity, details) as AnnotatedCommodity;

            // The same annotation but with another flags - annotated commodity is found
            Annotation details1 = new Annotation()
            {
                IsPriceFixated = true
            };

            Assert.NotNull(commodityPool.Find(symbol, details1));

            // Another annotation - no results
            Annotation details2 = new Annotation()
            {
                Tag = "tag"
            };

            Assert.Null(commodityPool.Find(symbol, details2));
        }