private static CurrencyHistory CreateTestHistory()
            {
                DateTime d1 = new DateTime(2020, 01, 01);
                DateTime d2 = new DateTime(2020, 01, 02);
                DateTime d3 = new DateTime(2020, 01, 03);
                DateTime d4 = new DateTime(2020, 01, 04);

                CurrencyRate[] r1 =
                {
                    new CurrencyRate("HUF", 1), new CurrencyRate("FOO", 10), new CurrencyRate("BAR", 100)
                };

                CurrencyRate[] r2 =
                {
                    new CurrencyRate("HUF", 2), new CurrencyRate("FOO", 20), new CurrencyRate("BAR", 200)
                };

                CurrencyRate[] r3 =
                {
                    new CurrencyRate("HUF", 3), new CurrencyRate("FOO", 30), new CurrencyRate("BAR", 300)
                };

                CurrencyRate[] r4 =
                {
                    new CurrencyRate("HUF", 4), new CurrencyRate("FOO", 40), new CurrencyRate("BAR", 400)
                };

                CurrencyRatesSnapshot s1 = new CurrencyRatesSnapshot(d1, r1);
                CurrencyRatesSnapshot s2 = new CurrencyRatesSnapshot(d2, r2);
                CurrencyRatesSnapshot s3 = new CurrencyRatesSnapshot(d3, r3);
                CurrencyRatesSnapshot s4 = new CurrencyRatesSnapshot(d4, r4);

                return(CurrencyHistory.CreateFromSnapshots(new[] { s1, s2, s3, s4 }));
            }
Beispiel #2
0
        public void Constructor()
        {
            CurrencyRate[] inputRates =
            {
                new CurrencyRate("HUF", 400),
                new CurrencyRate("USD", 1.2),
                new CurrencyRate("JPY", 133),
            };

            DateTime date = new DateTime(2018, 05, 20);

            // Act:
            CurrencyRatesSnapshot snapshot = new CurrencyRatesSnapshot(date, inputRates);

            // Assert:
            Assert.Equal(date, snapshot.Date);
            Assert.SetEqual(inputRates.Select(r => r.Code), snapshot.Select(r => r.Code));
            Assert.Equal(400, snapshot["HUF"].Rate);
        }
            public void ThrowsOnInconsistentInputCount()
            {
                CurrencyRate[] r1 =
                {
                    new CurrencyRate("HUF", 1)
                };

                CurrencyRate[] r2 =
                {
                    new CurrencyRate("HUF", 10), new CurrencyRate("FOO", 20)
                };

                CurrencyRatesSnapshot s1 = new CurrencyRatesSnapshot(DateTime.Now, r1);
                CurrencyRatesSnapshot s2 = new CurrencyRatesSnapshot(DateTime.Now, r2);

                Assert.ThrowsAny <Exception>(() =>
                {
                    CurrencyHistory.CreateFromSnapshots(new[] { s1, s2 });
                });
            }
            public void EurIsIgnored()
            {
                CurrencyRate[] r1 =
                {
                    new CurrencyRate("HUF", 1), new CurrencyRate("EUR", 2)
                };

                CurrencyRate[] r2 =
                {
                    new CurrencyRate("HUF", 10), new CurrencyRate("EUR", 20)
                };

                CurrencyRatesSnapshot s1 = new CurrencyRatesSnapshot(DateTime.Now, r1);
                CurrencyRatesSnapshot s2 = new CurrencyRatesSnapshot(DateTime.Now, r2);

                var history = CurrencyHistory.CreateFromSnapshots(new[] { s1, s2 });

                Assert.Equal(1, history.Count);
                Assert.Equal(1, history.Codes.Count);
                Assert.NotNull(history["huf"]);
            }