public void DieRollTracker_AddMultipleDieRollTest()
        {
            // setup test
            IDieRollTracker t = new DieRollTracker();

            // run test
            t.AddDieRoll(6, 4, typeof(RandomDieRoller));
            t.AddDieRoll(6, 3, typeof(RandomDieRoller));
            t.AddDieRoll(6, 1, typeof(RandomDieRoller));
            t.AddDieRoll(6, 6, typeof(RandomDieRoller));
            t.AddDieRoll(6, 2, typeof(RandomDieRoller));
            t.AddDieRoll(6, 4, typeof(RandomDieRoller));

            Task <IList <DieTrackingData> > task = t.GetTrackingDataAsync();

            task.Wait();
            IList <DieTrackingData> d = task.Result;

            // validate results
            Assert.IsNotNull(d);
            Assert.AreEqual(6, d.Count);
            foreach (DieTrackingData e in d)
            {
                Assert.AreEqual("RandomDieRoller", e.RollerType);
                Assert.AreEqual("6", e.DieSides);
                AssertHelpers.IsWithinRangeInclusive(1, 6, e.Result);
            }
        }
        public void DieRollTracker_GetFrequencyDataTest()
        {
            // setup test
            IDieRollTracker t = new DieRollTracker();
            List <AggregateDieTrackingData> aggExpected = this.SetupStatisticalTrackingData(t);

            // run test
            Task <IList <AggregateDieTrackingData> > view = t.GetFrequencyDataViewAsync();

            view.Wait();
            IList <AggregateDieTrackingData> data = view.Result;

            // validate results
            Task <IList <DieTrackingData> > task = t.GetTrackingDataAsync();

            task.Wait();
            IList <DieTrackingData> d = task.Result;

            Assert.IsNotNull(data);
            Assert.IsInstanceOfType(data, typeof(IList <AggregateDieTrackingData>));
            Assert.AreEqual(45, d.Count);
            Assert.AreEqual(23, data.Count);

            Assert.AreEqual(aggExpected.Count, data.Count);
            for (int i = 0; i < data.Count; i++)
            {
                Assert.AreEqual(aggExpected[i].RollerType, data[i].RollerType, "Failed roller type for item: " + i.ToString());
                Assert.AreEqual(aggExpected[i].DieSides, data[i].DieSides, "Failed die sides for item: " + i.ToString());
                Assert.AreEqual(aggExpected[i].Result, data[i].Result, "Failed result for item: " + i.ToString());
                Assert.AreEqual(aggExpected[i].Count, data[i].Count, "Failed count for item: " + i.ToString());
                Assert.AreEqual(aggExpected[i].Percentage, data[i].Percentage, "Failed percentage for item: " + i.ToString());
            }
        }
        public void DieRollTracker_ClearTest()
        {
            // setup test
            IDieRollTracker t = new DieRollTracker();

            t.AddDieRoll(6, 4, typeof(RandomDieRoller));
            t.AddDieRoll(6, 3, typeof(RandomDieRoller));
            t.AddDieRoll(6, 1, typeof(RandomDieRoller));
            t.AddDieRoll(6, 6, typeof(RandomDieRoller));
            t.AddDieRoll(6, 2, typeof(RandomDieRoller));
            t.AddDieRoll(6, 4, typeof(RandomDieRoller));

            Task <IList <DieTrackingData> > task = t.GetTrackingDataAsync();

            task.Wait();
            IList <DieTrackingData> d = task.Result;

            // run test
            t.Clear();

            // validate results
            task = t.GetTrackingDataAsync();
            task.Wait();
            IList <DieTrackingData> r = task.Result;

            Assert.AreEqual(0, r.Count);
        }
        public void DieRollTracker_LaodFromJsonTest()
        {
            // setup test
            IDieRollTracker t = new DieRollTracker();

            this.SetupTrackingSampleData(t);
            Task <string> task = t.ToJsonAsync();

            task.Wait();
            string data = task.Result;

            Assert.IsFalse(string.IsNullOrEmpty(data));

            // run test
            IDieRollTracker other = new DieRollTracker();
            Task            task2 = other.LoadFromJsonAsync(data);

            task2.Wait();

            Task <IList <DieTrackingData> > task3 = other.GetTrackingDataAsync("RandomDieRoller", "20");

            task.Wait();
            IList <DieTrackingData> list = task3.Result;

            // validate results
            Assert.AreEqual(14, list.Count);
            foreach (DieTrackingData e in list)
            {
                Assert.AreEqual("RandomDieRoller", e.RollerType);
                Assert.AreEqual("20", e.DieSides);
            }
        }
        public void DieRollTracker_ConstructorTest()
        {
            // setup test

            // run test
            IDieRollTracker t = new DieRollTracker();

            // validate results
            Assert.IsNotNull(t);
            Assert.IsInstanceOfType(t, typeof(IDieRollTracker));
            Assert.IsInstanceOfType(t, typeof(DieRollTracker));
        }
        public void DieRollTracker_GetFrequencyDataEmptyTest()
        {
            // setup test
            IDieRollTracker t = new DieRollTracker();

            // run test
            Task <IList <AggregateDieTrackingData> > view = t.GetFrequencyDataViewAsync();

            view.Wait();
            IList <AggregateDieTrackingData> data = view.Result;

            // validate results
            Assert.IsNotNull(data);
            Assert.IsInstanceOfType(data, typeof(IList <AggregateDieTrackingData>));
            Assert.AreEqual(0, data.Count);
        }
        public void DieRollTracker_ToJsonTest()
        {
            // setup test
            IDieRollTracker t = new DieRollTracker();

            this.SetupTrackingSampleData(t);

            // run test
            Task <string> task = t.ToJsonAsync();

            task.Wait();
            string data = task.Result;

            // validate results
            Assert.IsFalse(string.IsNullOrEmpty(data));
        }
        public void DieRollTracker_GetTrackingDataFilterDieSidesErrorTest()
        {
            // setup test
            IDieRollTracker t = new DieRollTracker();

            this.SetupTrackingSampleData(t);

            // run test
            Task <IList <DieTrackingData> > task = t.GetTrackingDataAsync("RandomDieRoller", "foo");

            task.Wait();
            IList <DieTrackingData> data = task.Result;

            // validate results
            Assert.AreEqual(0, data.Count);
        }
        public void DieRollTracker_GetTrackingDataAllTest()
        {
            // setup test
            IDieRollTracker t = new DieRollTracker();

            this.SetupTrackingSampleData(t);

            // run test
            Task <IList <DieTrackingData> > task = t.GetTrackingDataAsync();

            task.Wait();
            IList <DieTrackingData> data = task.Result;

            // validate results
            Assert.AreEqual(27, data.Count);
        }
        public void DieRollTracker_AddDieRollErrorsTest()
        {
            // setup test
            IDieRollTracker t = new DieRollTracker();

            // run test
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => t.AddDieRoll(1, 1, typeof(RandomDieRoller)));
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => t.AddDieRoll(0, 5, typeof(RandomDieRoller)));
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => t.AddDieRoll(-4, 5, typeof(RandomDieRoller)));
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => t.AddDieRoll(6, 8, typeof(RandomDieRoller)));
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => t.AddDieRoll(6, -2, typeof(RandomDieRoller)));
            Assert.ThrowsException <ArgumentNullException>(() => t.AddDieRoll(6, 4, null));
            Assert.ThrowsException <ArgumentException>(() => t.AddDieRoll(6, 4, this.GetType()));

            // validate results
        }
        public void DieRollTracker_GetTrackingDataFilterDieSidesTest()
        {
            // setup test
            IDieRollTracker t = new DieRollTracker();

            this.SetupTrackingSampleData(t);

            // run test
            Task <IList <DieTrackingData> > task = t.GetTrackingDataAsync(dieSides: "10");

            task.Wait();
            IList <DieTrackingData> data = task.Result;

            // validate results
            Assert.AreEqual(4, data.Count);
            foreach (DieTrackingData e in data)
            {
                Assert.AreEqual("10", e.DieSides);
            }
        }
        public void DieRollTracker_GetTrackingDataFilterDieTypeTest()
        {
            // setup test
            IDieRollTracker t = new DieRollTracker();

            this.SetupTrackingSampleData(t);

            // run test
            Task <IList <DieTrackingData> > task = t.GetTrackingDataAsync("RandomDieRoller");

            task.Wait();
            IList <DieTrackingData> data = task.Result;

            // validate results
            Assert.AreEqual(19, data.Count);
            foreach (DieTrackingData e in data)
            {
                Assert.AreEqual("RandomDieRoller", e.RollerType);
            }
        }
        public void DieRollTracker_AddDieRollTest()
        {
            // setup test
            IDieRollTracker t = new DieRollTracker();

            // run test
            t.AddDieRoll(6, 4, typeof(RandomDieRoller));
            Task <IList <DieTrackingData> > task = t.GetTrackingDataAsync();

            task.Wait();
            IList <DieTrackingData> d = task.Result;

            // validate results
            Assert.IsNotNull(d);
            Assert.AreEqual(1, d.Count);
            Assert.AreEqual("RandomDieRoller", d[0].RollerType);
            Assert.AreEqual("6", d[0].DieSides);
            Assert.AreEqual(4, d[0].Result);
            Assert.IsInstanceOfType(d[0].Id, typeof(Guid));
            Assert.IsInstanceOfType(d[0].Timpstamp, typeof(DateTime));
        }
        public void DieRollTracker_AddMultipleDieRollDieTypesTest()
        {
            // setup test
            IDieRollTracker t = new DieRollTracker();

            // run test
            t.AddDieRoll(6, 4, typeof(RandomDieRoller));
            t.AddDieRoll(6, 3, typeof(RandomDieRoller));
            t.AddDieRoll(6, 5, typeof(RandomDieRoller));
            t.AddDieRoll(6, 6, typeof(RandomDieRoller));
            t.AddDieRoll(6, 2, typeof(ConstantDieRoller));
            t.AddDieRoll(6, 2, typeof(ConstantDieRoller));

            Task <IList <DieTrackingData> > task = t.GetTrackingDataAsync();

            task.Wait();
            IList <DieTrackingData> d = task.Result;

            // validate results
            Assert.IsNotNull(d);
            Assert.AreEqual(6, d.Count);
            int i;

            for (i = 0; i < 2; i++)
            {
                DieTrackingData e = d[i];
                Assert.AreEqual("ConstantDieRoller", e.RollerType);
                Assert.AreEqual("6", e.DieSides);
                AssertHelpers.IsWithinRangeInclusive(1, 6, e.Result);
            }

            for (int x = i; x < 6; x++)
            {
                DieTrackingData e = d[x];
                Assert.AreEqual("RandomDieRoller", e.RollerType);
                Assert.AreEqual("6", e.DieSides);
                AssertHelpers.IsWithinRangeInclusive(1, 6, e.Result);
            }
        }