コード例 #1
0
        public void Test_Empty_Expiry()
        {
            var input = new List <ContractDetails> {
                new ContractDetails()
            };

            Assert.Throws <InvalidDataException>(() => ContractDetailsExpiryEx.ContractDetailsExpiryFilter(input, 0))
            .WriteMessageTo(Write);
        }
コード例 #2
0
        public void Test_Expiry_Single()
        {
            var input = new List <ContractDetails> {
                new ContractDetails {
                    Contract = { LastTradeDateOrContractMonth = "202012" }
                }
            };

            var output = ContractDetailsExpiryEx.ContractDetailsExpiryFilter(input, 0);

            Assert.Equal(input.Single(), output.Single());
        }
コード例 #3
0
        public void Test_Expiry_Multiple()
        {
            var input = new List <ContractDetails>
            {
                new ContractDetails {
                    Contract = { LastTradeDateOrContractMonth = "202012" }
                },
                new ContractDetails {
                    Contract = { LastTradeDateOrContractMonth = "202003" }
                },
                new ContractDetails {
                    Contract = { LastTradeDateOrContractMonth = "202011" }
                },
                new ContractDetails {
                    Contract = { LastTradeDateOrContractMonth = "202001" }
                },
                new ContractDetails {
                    Contract = { LastTradeDateOrContractMonth = "202007" }
                },
                new ContractDetails {
                    Contract = { LastTradeDateOrContractMonth = "202003" }
                }
            };

            var output = ContractDetailsExpiryEx.ContractDetailsExpiryFilter(input, 0);

            Assert.Equal(input[3], output.Single());

            output = ContractDetailsExpiryEx.ContractDetailsExpiryFilter(input, 1);
            Assert.Equal(2, output.Count);

            output = ContractDetailsExpiryEx.ContractDetailsExpiryFilter(input, 4);
            Assert.Equal(input[0], output.Single());

            output = ContractDetailsExpiryEx.ContractDetailsExpiryFilter(input, 5);
            Assert.True(!output.Any());
        }