/// <summary>Initializes a new instance of the <see cref="ScoreCalculator" /> class.</summary>
 /// <param name="shred30Contacts">The shred30 contacts.</param>
 /// <param name="contactArrangers">The contact arrangers.</param>
 /// <param name="validators">The validators.</param>
 /// <param name="addCalculator">The add calculator.</param>
 public StandardShred30ScoreCalculator(IEnumerable <IShred30Contact> shred30Contacts, IEnumerable <IShred30ContactArranger> contactArrangers, IEnumerable <IShredContact30Validator> validators, IAddCalculator addCalculator, IUniqueCalculator uniqueCalculator)
 {
     this.Shred30Contacts  = shred30Contacts;
     this.ContactArrangers = contactArrangers;
     this.Validators       = validators;
     this.AddCalculator    = addCalculator;
     this.UniqueCalculator = uniqueCalculator;
 }
Ejemplo n.º 2
0
        public void CanGetUniqueNumberOfContacts_NotAllUnique()
        {
            List <IShred30Contact> contacts = new List <IShred30Contact>()
            {
                new Shred30Trick(OrdinalSideType.Left, MockFootbagTricks.Ripwalk),
                new Shred30Trick(OrdinalSideType.Right, MockFootbagTricks.Blur),
                new Shred30Trick(OrdinalSideType.Right, MockFootbagTricks.Dimwalk),
                new Shred30Trick(OrdinalSideType.Left, MockFootbagTricks.Ripwalk)
            };

            this.UniqueCalculator = new OpenAddsBasedUniqueCalculator();

            Assert.AreEqual(3, this.UniqueCalculator.GetNumberOfUniqueContacts(contacts));
        }
Ejemplo n.º 3
0
        public void CanGetUniqueContactsWithDoubleDowns_NonUnique()
        {
            List <IShred30Contact> contacts = new List <IShred30Contact>()
            {
                new Shred30Trick(OrdinalSideType.Left, MockFootbagTricks.Ripwalk),
                new Shred30Trick(OrdinalSideType.Right, MockFootbagTricks.Barfly),
                new Shred30Trick(OrdinalSideType.Left, MockFootbagTricks.Blur),
                new Shred30Trick(OrdinalSideType.Left, MockFootbagTricks.DownOverDown)
            };

            this.UniqueCalculator = new OpenAddsBasedUniqueCalculator();

            IEnumerable <IShred30Contact> actualUniqueContacts = this.UniqueCalculator.GetUniqueContacts(contacts);

            List <IShred30Contact> expectedUniqueContacts = new List <IShred30Contact>
            {
                new Shred30Trick(OrdinalSideType.Left, MockFootbagTricks.Ripwalk),
                new Shred30Trick(OrdinalSideType.Right, MockFootbagTricks.Barfly),
                new Shred30Trick(OrdinalSideType.Left, MockFootbagTricks.Blur)
            };

            Assert.IsTrue(actualUniqueContacts.SequenceEqual(expectedUniqueContacts, new Shred30ContactComparer()));
        }
Ejemplo n.º 4
0
        public void CanGetUniqueContacts_IntermediateLevelAdds()
        {
            List <IShred30Contact> contacts = new List <IShred30Contact>()
            {
                new Shred30Trick(OrdinalSideType.Left, MockFootbagTricks.Ripwalk),
                new Shred30Trick(OrdinalSideType.Right, MockFootbagTricks.Barfly),
                new Shred30Trick(OrdinalSideType.Left, MockFootbagTricks.Blur),
                new Shred30Trick(OrdinalSideType.Left, MockFootbagTricks.Mirage)
            };

            this.UniqueCalculator = new IntermediateAddsBasedUniqueCalculator();

            IEnumerable <IShred30Contact> actualUniqueContacts = this.UniqueCalculator.GetUniqueContacts(contacts);

            List <IShred30Contact> expectedUniqueContacts = new List <IShred30Contact>
            {
                new Shred30Trick(OrdinalSideType.Left, MockFootbagTricks.Ripwalk),
                new Shred30Trick(OrdinalSideType.Right, MockFootbagTricks.Barfly),
                new Shred30Trick(OrdinalSideType.Left, MockFootbagTricks.Blur),
                new Shred30Trick(OrdinalSideType.Left, MockFootbagTricks.Mirage)
            };

            Assert.IsTrue(actualUniqueContacts.SequenceEqual(expectedUniqueContacts, new Shred30ContactComparer()));
        }
Ejemplo n.º 5
0
        private StandardShred30ScoreCalculator GetScoreCalculator(IEnumerable <IShred30Contact> shred30Contacts, bool useXDex = true, IShred30ContactArranger contactArranger = null, IShredContact30Validator validator = null, IUniqueCalculator uniqueCalculator = null)
        {
            IAddCalculator addCalculator;

            if (useXDex)
            {
                addCalculator = new StandardAddCalculator();
            }
            else
            {
                addCalculator = new NoXDexAddCalculator();
            }

            return(new StandardShred30ScoreCalculator(
                       shred30Contacts,
                       contactArranger == null ? new List <IShred30ContactArranger>() : new List <IShred30ContactArranger> {
                contactArranger
            },
                       validator == null ? new List <IShredContact30Validator>() : new List <IShredContact30Validator> {
                validator
            },
                       addCalculator,
                       uniqueCalculator == null ? new OpenAddsBasedUniqueCalculator() : uniqueCalculator
                       ));
        }