public void Test_Empty_Expiry()
        {
            var input = new List <ContractDetails> {
                new ContractDetails()
            };

            Assert.Throws <InvalidDataException>(() => ContractDetailsExpiryEx.ContractDetailsExpiryFilter(input, 0))
            .WriteMessageTo(Write);
        }
        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());
        }
        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());
        }