public void should_get_active_contracts()
        {
            // arrange
            var repo   = new Mock <IMusicContractsRepo>();
            var dpList = new List <DistributionPartner>
            {
                new DistributionPartner("test", "test")
            };

            repo.Setup(x => x.GetList(It.IsAny <List <DistributionPartner> >()))
            .Returns(new List <MusicContract>
            {
                new MusicContract("art", "titl", dpList, new DateTime(2017, 01, 01), null)
            });

            var service = new MusicContractService(repo.Object);


            // act
            var result = service.GetActiveList(dpList, new DateTime(2017, 03, 01), "test");

            // assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count);
        }
Ejemplo n.º 2
0
        public MusicContractServiceTests()
        {
            _distributionPartnerContractRepository = new Mock <IRepository <DistributionPartnerContract> >();
            _musicContracRepository = new Mock <IRepository <MusicContract> >();
            // set up mock version's method
            _distributionPartnerContractRepository.Setup(x => x.Find(It.IsAny <Func <DistributionPartnerContract, bool> >()))
            .Returns(new List <DistributionPartnerContract>
            {
                new DistributionPartnerContract()
                {
                    Partner = "YouTube", Usage = DistributionType.Streaming
                },
                new DistributionPartnerContract()
                {
                    Partner = "iTunes", Usage = DistributionType.Streaming
                }
            });

            _musicContracRepository.Setup(x => x.Find(It.IsAny <Func <MusicContract, bool> >()))
            .Returns(new List <MusicContract>
            {
                new MusicContract()
                {
                    Artist = "Tinie Tempah", Title = "Miami 2 Ibiza", Usages = new List <DistributionType> {
                        DistributionType.DigitalDownload
                    }, StartDate = new DateTime(2012, 02, 01)
                },
                new MusicContract()
                {
                    Artist = "Monkey Claw", Title = "Christmas Special", Usages = new List <DistributionType> {
                        DistributionType.Streaming
                    }, StartDate = new DateTime(2012, 12, 25), EndDate = new DateTime(2012, 12, 31)
                }
            });

            // create thing being tested with a mock dependency
            _musicContractService = new MusicContractService(_musicContracRepository.Object, _distributionPartnerContractRepository.Object);
        }