Ejemplo n.º 1
0
        public void ByAllProperties_TrueOnMatchedObjectInstancesWithCustomComparer()
        {
            B b  = new B(6, new A(5, "Foo")),
              b2 = new B(6, new A(5, "Bar"));

            Assert.Equal(b, b2, GenericEqualityComparer <B> .ByAllMembers(new[] { A.IntegerOnlyComparer }));
        }
Ejemplo n.º 2
0
        public void ByAllProperties_FalseOnUnMatchedObjectInstances()
        {
            A a = new A(5, "Foo"),
              b = new A(3, "Bar");

            Assert.NotEqual(a, b, GenericEqualityComparer <A> .ByAllMembers());
        }
Ejemplo n.º 3
0
        public void Constructor_StoresException()
        {
            var exception = new ArgumentNullException("foo");
            var poison    = new Poison <int>(42, exception);

            Assert.Equal(new ExceptionDetails(exception), poison.Exception, GenericEqualityComparer <ExceptionDetails> .ByAllMembers());
        }
Ejemplo n.º 4
0
            public void UsesProvidedGenericEqualityComparer()
            {
                var comparer = new GenericEqualityComparer <int>();

                Assert.That(2 + 2, Is.EqualTo(4).Using(comparer));
                Assert.That(comparer.WasCalled, "Comparer was not called");
            }
Ejemplo n.º 5
0
        /// <summary>
        /// Determines if the objects are equal
        /// </summary>
        /// <param name="obj">Object to compare to</param>
        /// <returns>Determines if the commands are equal</returns>
        public override bool Equals(object obj)
        {
            Command OtherCommand = obj as Command;

            if (OtherCommand == null)
            {
                return(false);
            }
            if (OtherCommand.SQLCommand != SQLCommand ||
                OtherCommand.CommandType != CommandType ||
                Parameters.Count != OtherCommand.Parameters.Count)
            {
                return(false);
            }
            GenericEqualityComparer <object> Comparer = new GenericEqualityComparer <object>();

            for (int x = 0; x < Parameters.Count; ++x)
            {
                if (!Comparer.Equals(Parameters[x], OtherCommand.Parameters[x]))
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Saves (inserts/updates) an object based on the following criteria:
        /// 1) If autoincrement is set to true and the primary key is the default value, it inserts
        /// 2) If autoincrement is set to true and the primary key is not the default value, it updates
        /// 3) If autoincrement is set to false and the primary key is the default value, it inserts
        /// 4) If autoincrement is set to false and the primary key is not the default value,
        /// it does an Any call to see if the item is already in the database. If it is, it does an
        /// update. Otherwise it does an insert.
        /// On an insert, the primary key property is updated with the resulting value of the insert.
        /// </summary>
        /// <param name="Object">Object to save</param>
        /// <param name="Parameters">Extra parameters to be added to the insert/update function</param>
        public virtual void Save <PrimaryKeyType>(ClassType Object, params IParameter[] Parameters)
        {
            PrimaryKeyType PrimaryKeyVal = (PrimaryKeyType)GetPrimaryKey(Object);
            GenericEqualityComparer <PrimaryKeyType> Comparer = new GenericEqualityComparer <PrimaryKeyType>();

            if (Comparer.Equals(PrimaryKeyVal, default(PrimaryKeyType)))
            {
                PrimaryKeyVal = Insert <PrimaryKeyType>(Object, Parameters);
                PrimaryKeyMapping.CopyRightToLeft(PrimaryKeyVal, Object);
                return;
            }
            if (AutoIncrement)
            {
                Update(Object, Parameters);
                return;
            }
            Parameter <PrimaryKeyType> Param1 = new Parameter <PrimaryKeyType>(PrimaryKeyVal, PrimaryKey, ParameterStarter);
            ClassType TempVal = Any(PrimaryKey, null, null, Param1);

            if (TempVal == null)
            {
                PrimaryKeyVal = Insert <PrimaryKeyType>(Object, Parameters);
                PrimaryKeyMapping.CopyRightToLeft(PrimaryKeyVal, Object);
                return;
            }
            Update(Object, Parameters);
        }
        public void GetHashCodeTest()
        {
            var Comparer = new GenericEqualityComparer <string>();

            Assert.Equal("A".GetHashCode(), Comparer.GetHashCode("A"));
            Assert.Equal("B".GetHashCode(), Comparer.GetHashCode("B"));
        }
Ejemplo n.º 8
0
        public async Task <IEnumerable <DishPreviewDto> > GetDishesByIngredients(FilterRequest filterRequest)
        {
            var dishComparer = GenericEqualityComparer <Dish> .GetEqualityComparer((d1, d2) => d1.Id == d2.Id, d => d.Id);

            var query = (await(filterRequest.IncludeIngredients?.Any() ?? false
                ? _unitOfWork.Dishes.GetByIngredientsAsync(filterRequest.IncludeIngredients)
                : _unitOfWork.Dishes.GetDishesWithIngredientsCategoriesAndRatingsAsync(null, null))).AsQueryable();

            query = query.Where(d => d.Name.IndexOf(filterRequest.Name, StringComparison.InvariantCultureIgnoreCase) != -1);

            query = filterRequest.ExcludeIngredients?.Any() ?? false
                ? query.Except(await _unitOfWork.Dishes.GetByIngredientsAsync(filterRequest.ExcludeIngredients), dishComparer)
                : query;


            query = filterRequest.IncludeIngredients?.Any() ?? false
                ? query.Where(
                res => res.DishIngredients.Select(di => di.IngredientId)
                .Intersect(filterRequest.IncludeIngredients)
                .Count()
                / (double)filterRequest.IncludeIngredients.Count()
                >= 0.5)
                : query;

            return(query.Select(_mapper.Map <Dish, DishPreviewDto>)
                   .ToList());
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Initializes new instance of <see cref="AbstractionEventHandlerLookup{TAbstraction,TImplementation}"/>.
        /// </summary>
        public AbstractionEventHandlerLookup()
        {
            var comparer = new GenericEqualityComparer <EventHandler <TAbstraction> >(
                (key, otherKey) => ReferenceEquals(key.Target, otherKey.Target) && ReferenceEquals(key.GetMethodInfo(), otherKey.GetMethodInfo()),
                key => ((key.Target?.GetHashCode() ?? 0) * 397) ^ (key.GetMethodInfo()?.GetHashCode() ?? 0));

            _lookup = new Dictionary <EventHandler <TAbstraction>, AbstractionEventHandlerContext <TImplementation> >(comparer);
        }
        public void CompareNullNonValueType()
        {
            var Comparer = new GenericEqualityComparer <string>();

            Assert.True(Comparer.Equals(null, null));
            Assert.False(Comparer.Equals(null, "B"));
            Assert.False(Comparer.Equals("B", null));
        }
        public void AddIfUniqueParamsWithNullIEqualityComparer()
        {
            var TestObject = new ConcurrentBag <int>(new int[] { 1, 2, 3, 4, 5, 6 });
            GenericEqualityComparer <int> Comparer = null;

            Assert.False(TestObject.AddIfUnique(Comparer, new int[] { 1 }));
            Assert.True(TestObject.AddIfUnique(Comparer, new int[] { 7 }));
        }
        public void CompareValueType()
        {
            var Comparer = new GenericEqualityComparer <int>();

            Assert.True(Comparer.Equals(0, 0));
            Assert.False(Comparer.Equals(0, 1));
            Assert.False(Comparer.Equals(1, 0));
        }
        public void Compare()
        {
            var Comparer = new GenericEqualityComparer <string>();

            Assert.True(Comparer.Equals("A", "A"));
            Assert.False(Comparer.Equals("A", "B"));
            Assert.False(Comparer.Equals("B", "A"));
        }
Ejemplo n.º 14
0
        public void IndexOfWithComparerTest()
        {
            const int expected = 1;
            var       comparer = new GenericEqualityComparer <Fake>(Equals);

            var result = GetEnumerableFakeList().IndexOf(new Fake("Test2"), comparer);

            result.Should().Be(expected);
        }
Ejemplo n.º 15
0
        protected ReactiveListViewModel(IReactiveData <TModel> reactive, ISchedulersFactory schedulersFactory)
        {
            this.reactive          = reactive ?? throw new ArgumentNullException(nameof(reactive));
            this.schedulersFactory = schedulersFactory ?? throw new ArgumentNullException(nameof(schedulersFactory));

            Comparer = new GenericEqualityComparer <TModel>((x, y) => Equals(GetId(x), GetId(y)));

            Init();
        }
Ejemplo n.º 16
0
        public override void Validate(ObjectType Object)
        {
            GenericEqualityComparer <string> Comparer = new GenericEqualityComparer <string>();

            if (Comparer.Equals(ItemToValidate(Object), DefaultValue))
            {
                throw new NotValid(ErrorMessage);
            }
        }
Ejemplo n.º 17
0
        public override void Validate(ObjectType Object)
        {
            GenericEqualityComparer <DataType> Comparer = new GenericEqualityComparer <DataType>();

            if (!Comparer.Equals(ItemToValidate(Object), Value))
            {
                throw new NotValid(ErrorMessage);
            }
        }
Ejemplo n.º 18
0
        public void ForExpression_FirstNameChar_OK()
        {
            Func <Customer, Customer, bool> ExpressionComparator = (a, b) => a.Name.FirstOrDefault() == b.Name.FirstOrDefault();

            instance = new GenericEqualityComparer <Customer>(ExpressionComparator);

            var result = customers.Distinct(instance).Count();

            Assert.AreEqual(4, result);
        }
Ejemplo n.º 19
0
        public void ForField_ID()
        {
            Func <Customer, object> fieldComparator = a => a.ID;

            instance = new GenericEqualityComparer <Customer>(fieldComparator);

            var result = customers.Distinct(instance).Count();

            Assert.AreEqual(6, result);
        }
        public void Queue_GeneratesExpectedOnQueueAction()
        {
            var actionType  = DurableJobQueueActionType.Queued;
            var observation = SubscribeForAction(actionType, (store, item, poison) =>
            {
                store.Queue(item);
            });

            Assert.True(observation.Action.ActionType == actionType && GenericEqualityComparer <TQueue> .ByAllMembers().Equals(observation.Action.Input, observation.Input));
        }
Ejemplo n.º 21
0
        public void Subscribe_ResumesInProperQueuePositionAfterReadingMaximumDuringInterval()
        {
            int maxToSlurp = 3;
            var jobStorage = A.Fake <IDurableJobQueue <Incoming, Incoming> >();
            var scheduler  = new HistoricalScheduler();
            var monitor    = new DurableJobQueueMonitor <Incoming, Incoming>(jobStorage, maxToSlurp, DurableJobQueueMonitor.DefaultPollingInterval,
                                                                             scheduler);

            List <Incoming> incomingItems = new List <Incoming>();

            var queuedItems = Enumerable.Repeat(Item.From(new Incoming()
            {
                Id = 1
            }), 3)
                              .Concat(new []
            {
                Item.From(new Incoming()
                {
                    Id = 456
                }),
                Item.From(new Incoming()
                {
                    Id = 222
                }),
                Item.From(new Incoming()
                {
                    Id = 8714
                })
            })
                              .Concat(Enumerable.Repeat(Item.From(new Incoming()
            {
                Id = 5
            }), 2))
                              .Concat(Enumerable.Repeat(Item.From(new Incoming()
            {
                Id = 2
            }), 4))
                              .Concat(Enumerable.Repeat(Item.From(new Incoming()
            {
                Id = 3
            }), 3))
                              .ToArray();

            A.CallTo(() => jobStorage.NextQueuedItem()).ReturnsNextFromSequence(queuedItems);

            using (var subscription = monitor.Subscribe(publishedItem => { incomingItems.Add(publishedItem); }))
            {
                scheduler.AdvanceBy(monitor.PollingInterval);
                scheduler.AdvanceBy(monitor.PollingInterval);

                Assert.True(queuedItems.Take(maxToSlurp * 2)
                            .Select(item => item.Value)
                            .SequenceEqual(incomingItems, GenericEqualityComparer <Incoming> .ByAllMembers()));
            }
        }
        public bool UpdateWhenChanged(IEnumerable <MetricDefinition> metricDefinitions)
        {
            if (this.MetricDefinitions == null || !this.MetricDefinitions.SequenceEqual(
                    metricDefinitions,
                    GenericEqualityComparer <MetricDefinition> .CreateComparer((a, b) => a.ValueEquals(b), a => a.GetHashCode())))
            {
                this.MetricDefinitions = metricDefinitions;
                return(true);
            }

            return(false);
        }
 public void Top_keyselector01()
 {
     Assert.True(new[] { 0, 5, 10, 15, 20, 25 }.Select(x => new ComparableClass2 {
         Value = x
     })
                 .Top(3, x => x.Value)
                 .OrderByDescending(x => x.Value)
                 .SequenceEqual(new[] { 25, 20, 15 }.Select(x => new ComparableClass2 {
         Value = x
     }),
                                GenericEqualityComparer <ComparableClass2> .By(x => x.Value)));
 }
 public void Bottom_keyselector01()
 {
     Assert.True(new[] { 25, 20, 15, 10, 5, 0 }.Select(x => new ComparableClass2 {
         Value = x
     })
                 .Bottom(3, x => x.Value)
                 .OrderBy(x => x.Value)
                 .SequenceEqual(new[] { 0, 5, 10 }.Select(x => new ComparableClass2 {
         Value = x
     }),
                                GenericEqualityComparer <ComparableClass2> .By(x => x.Value)));
 }
Ejemplo n.º 25
0
        public void ForField_AllCityMadrid_OK()
        {
            Func <Customer, object> fieldComparator = a => a.City;

            customers.ForEach(a => a.City = "Madrid");

            instance = new GenericEqualityComparer <Customer>(fieldComparator);

            var result = customers.Distinct(instance).Count();

            Assert.AreEqual(1, result);
        }
Ejemplo n.º 26
0
        public ActionResult Index(String faction = "horde", String realm = "bonechewer", Int32 count = 20, Int32 results = 25, Int32 buymin = 250)
        {
            var StartDate = DateTime.Today.Subtract(new TimeSpan(3, 0, 0, 0));

            // EqulityComparer for Item
            var itemComparer = new GenericEqualityComparer<Item>(
                (a, b) => a.ID == b.ID,
                (a) => a.GetHashCode()
            );
            // Get a set of Item:IE<Auction>
            var items = (from a in wac.Auctions
                           where a.MyAuctionHouse.Realm == realm
                              && a.MyAuctionHouse.Faction == faction
                              && a.TimeStamp >= StartDate
                              && a.TimeStamp <= DateTime.Now
                              && a.Buyout > 0
                           select a.MyItem).ToList();

            items = items.Distinct(itemComparer).ToList();

            // result collection
            ConcurrentBag<AuctionSummary> bag = new ConcurrentBag<AuctionSummary>();
            Parallel.ForEach(items, new ParallelOptions { MaxDegreeOfParallelism = 8 }, (itemAuctions) =>
                {
                    AuctionSummary ret = new AuctionSummary();
                    AuctionAPIController api = new AuctionAPIController();

                    var result = api.SingleZStats(realm, faction, itemAuctions.ID, StartDate, DateTime.Now, .15, 250);

                    // If there is no variance, there is no volatility
                    if (result.StdDev != 0.0 && result.AvgSeen >= count)
                    {
                        ret.ItemID = itemAuctions.ID;
                        ret.ItemName = itemAuctions.Name;
                        ret.Mean = Math.Round(result.Mean, 4);
                        ret.MinBuyout = result.CurrMin;
                        ret.StdDev = Math.Round(result.StdDev, 4);
                        ret.ZValue = Math.Round(result.ZValue, 4);

                        bag.Add(ret);
                    }
                }
            );

            var vmIndex = new HomeIndexVM() { Faction = faction, Realm = realm };
            vmIndex.Items = bag.OrderBy(a => a.ZValue).Take(results).ToList();

            ViewData["faction"] = faction;
            ViewData["realm"] = realm;

            return View(vmIndex);
        }
        public void In_comparer01()
        {
            var value = new ComparableClass2()
            {
                Value = 1
            };
            var source = new[] { 1, 2, 3 }.Select(x => new ComparableClass2()
            {
                Value = x
            });

            Assert.IsTrue(value.In(source, GenericEqualityComparer <ComparableClass2> .By(x => x.Value)));
        }
Ejemplo n.º 28
0
        public void GetQueued_PreservesOrdering()
        {
            var storage = JobStorageFactory();

            var queueItems = Fixture.CreateMany <TQueue>(15).ToList();

            foreach (var item in queueItems)
            {
                storage.Queue(item);
            }

            Assert.True(queueItems.SequenceEqual(storage.GetQueued(), GenericEqualityComparer <TQueue> .ByAllMembers()));
        }
Ejemplo n.º 29
0
        public override void Validate(ObjectType Object)
        {
            GenericEqualityComparer <DataType> Comparer = new GenericEqualityComparer <DataType>();

            foreach (DataType Item in ItemToValidate(Object))
            {
                if (Comparer.Equals(Item, Value))
                {
                    return;
                }
            }
            throw new NotValid(ErrorMessage);
        }
        public void Bottom_comparer01()
        {
            var comparer = new ComparableClass2Comparer();

            Assert.True(new[] { 25, 20, 15, 10, 5, 0 }.Select(x => new ComparableClass2 {
                Value = x
            })
                        .Bottom(3, comparer)
                        .OrderBy(x => x, comparer)
                        .SequenceEqual(new[] { 0, 5, 10 }.Select(x => new ComparableClass2 {
                Value = x
            }),
                                       GenericEqualityComparer <ComparableClass2> .By(x => x)));
        }
Ejemplo n.º 31
0
        public void DictionariesAreEqualWhenUsingCustomKeyComparer()
        {
            var comparer = new GenericEqualityComparer <int>((x, y) => x == y, HashCodeUtility.GetPersistentHashCode);
            var dict1    = new Dictionary <int, int>(comparer)
            {
                { 1, 1 }, { 2, 2 }, { 3, 3 }
            };
            var dict2 = new Dictionary <int, int>(comparer)
            {
                { 1, 1 }, { 2, 2 }, { 3, 3 }
            };

            Assert.IsTrue(DictionaryUtility.AreEqual(dict1, dict2));
        }
Ejemplo n.º 32
0
        public void GenericEqualityComparer_Equals()
        {
            var strs = new string[] { "Abr", "Adr", "Afr" };
            var gcc0 = new GenericEqualityComparer<string>(i => i[0], withoutHash: true);
            var gcc1 = new GenericEqualityComparer<string>(i => i[1], withoutHash: true);
            var gcc2 = new GenericEqualityComparer<string>(i => i[2]);

            var cnt0 = strs.Distinct(gcc0).Count();
            var cnt1 = strs.Distinct(gcc1).Count();
            var cnt2 = strs.Distinct(gcc2).Count();

            Assert.AreEqual(1, cnt0, "All strings must equals by first character");
            Assert.AreEqual(3, cnt1, "All strings must not equals by second character");
            Assert.AreEqual(3, cnt2, "All strings must not equals by third character becase we not disable to use hash");
        }
		public void GetHashCodeTest()
		{
			var testSamples = new List<UriFormat>
			{
				UriFormat.SafeUnescaped,
				UriFormat.Unescaped,
				UriFormat.UriEscaped
			};

			var comparer = new GenericEqualityComparer<UriFormat>((x, y) => x == y, x => x.GetHashCode());

			for (var index = 0; index < testSamples.Count; index++)
			{
				Assert.AreEqual(testSamples[index].GetHashCode(), comparer.GetHashCode(testSamples[index]));
			}
		}
		public void NotEqualsTest()
		{
			var first = new List<UriFormat>
			{
				UriFormat.SafeUnescaped,
				UriFormat.Unescaped,
				UriFormat.UriEscaped
			};

			var second = new List<UriFormat>
			{
				UriFormat.Unescaped,
				UriFormat.SafeUnescaped,
				UriFormat.UriEscaped
			};

			var comparer = new GenericEqualityComparer<UriFormat>((x, y) => x == y, x => x.GetHashCode());

			var actualResult = first.SafeSequenceEqual(second, comparer);

			Assert.IsFalse(actualResult);
		}
 public void Constructor_NullComparison_ThrowsException()
 {
     GenericEqualityComparer<string> c = new GenericEqualityComparer<string>(null);
 }
        public void EqualsWithEnumerableSubModelsReturnsExpectedResult(
            IEnumerable<SubModel> x, IEnumerable<SubModel> y, bool expected)
        {
            var sut = new GenericEqualityComparer<IEnumerable<SubModel>>();

            Assert.Equal(expected, sut.Equals(x, y));
        }
        public void GetHashCodeForValidObjectReturnsObjectHashCode()
        {
            var sut = new GenericEqualityComparer<Model>();
            var model = new Model();

            Assert.Equal(model.GetHashCode(), sut.GetHashCode(model));
        }
 public void Constructor_NonNullComparison_DoesNotThrowException()
 {
     GenericEqualityComparer<string> c = new GenericEqualityComparer<string>((x, y) => { return false; });
 }
        public void EqualsWithSubModelsReturnsExpectedResult(SubModel x, SubModel y, bool expected)
        {
            var sut = new GenericEqualityComparer<SubModel>();

            Assert.Equal(expected, sut.Equals(x, y));
        }
        public void GetHashCodeForNullObjectReturnsZero()
        {
            var sut = new GenericEqualityComparer<Model>();

            Assert.Equal(0, sut.GetHashCode(null));
        }
        public void EqualsWithStringsReturnsExpectedResult(string x, string y, bool expected)
        {
            var sut = new GenericEqualityComparer<string>();

            Assert.Equal(expected, sut.Equals(x, y));
        }
        public void EqualsWithListsReturnsExpectedResult(List<int> x, List<int> y, bool expected)
        {
            var sut = new GenericEqualityComparer<List<int>>();

            Assert.Equal(expected, sut.Equals(x, y));
        }
 public void Constructor_ThrowsOnNullFunc()
 {
     Assert.Throws<ArgumentNullException>(() => { var comparer = new GenericEqualityComparer<A>(null); });
 }
 public void Constructor_ThrowsOnNullHashGenerator()
 {
     Assert.Throws<ArgumentNullException>(() => { var comparer = new GenericEqualityComparer<A>((a, b) => a.Integer == b.Integer, null); });
 }
Ejemplo n.º 45
0
 /// <summary>
 /// Determines if the objects are equal
 /// </summary>
 /// <param name="obj">Object to compare to</param>
 /// <returns>Determines if the commands are equal</returns>
 public override bool Equals(object obj)
 {
     Command OtherCommand = obj as Command;
     if (OtherCommand == null)
         return false;
     if (OtherCommand.SQLCommand != SQLCommand
         || OtherCommand.CommandType != CommandType
         || Parameters.Count != OtherCommand.Parameters.Count)
         return false;
     GenericEqualityComparer<object> Comparer = new GenericEqualityComparer<object>();
     for (int x = 0; x < Parameters.Count; ++x)
     {
         if (!Comparer.Equals(Parameters[x], OtherCommand.Parameters[x]))
             return false;
     }
     return true;
 }
        public void EqualsWithEnumsReturnsExpectedResult(Enum x, Enum y, bool expected)
        {
            var sut = new GenericEqualityComparer<Enum>();

            Assert.Equal(expected, sut.Equals(x, y));
        }
        public void EqualsWithIntsReturnsExpectedResult(int x, int y, bool expected)
        {
            var sut = new GenericEqualityComparer<int>();

            Assert.Equal(expected, sut.Equals(x, y));
        }
 /// <summary>
 /// Determines if the property is valid
 /// </summary>
 /// <param name="value">Value to check</param>
 /// <param name="validationContext">Validation context</param>
 /// <returns>The validation result</returns>
 protected override ValidationResult IsValid(object value, ValidationContext validationContext)
 {
     if (value==null)
         return ValidationResult.Success;
     GenericEqualityComparer<IComparable> Comparer = new GenericEqualityComparer<IComparable>();
     IEnumerable ValueList = value as IEnumerable;
     IComparable ValueTemp = 0;
     foreach (IComparable Item in ValueList)
     {
         ValueTemp = (IComparable)Value.To<object>(Item.GetType());
         break;
     }
     foreach (IComparable Item in ValueList)
     {
         if (Comparer.Equals(Item, ValueTemp))
             return new ValidationResult(FormatErrorMessage(validationContext.DisplayName));
     }
     return ValidationResult.Success;
 }
Ejemplo n.º 49
0
        public ZStatsResults SingleZStats(String realm, String faction, Int32 itemID, DateTime startTime, DateTime endTime, double percentile = .25, Int32 minPrice = 250)
        {
            ZStatsResults result = new ZStatsResults();
            var auctions = (from auc in wac.Auctions
                         where auc.MyAuctionHouse.Realm == realm
                            && auc.MyAuctionHouse.Faction == faction
                            && auc.MyItem.ID == itemID
                            && auc.TimeStamp >= startTime
                            && auc.TimeStamp < endTime
                            // I work with buyouts, not concerned with bid only operations
                            && auc.Buyout > 0
                         select auc).ToList();

            // stop if there is no results
            if (auctions.Count() == 0)
            {
                return result;
            }
            // Finds distinct auctions
            GenericEqualityComparer<Auction> comparer = new GenericEqualityComparer<Auction>(
                (a, b) => a.AucID == b.AucID,
                (a) => a.GetHashCode()
            );
            var buyouts = auctions.Distinct(comparer).SelectMany(a =>
                {
                    return Enumerable.Range(0, a.Quanity).Select(buy => a.Buyout / a.Quanity * 1.0);
                }
            ).ToList();

            // Calculates the average number of items found per TimeStamp
            result.AvgSeen = auctions.Count() * 1.0 / auctions.GroupBy(a => a.TimeStamp).Count();

            // buyouts in a certain percentile
            var culledBuyouts = buyouts.OrderBy(a => a).Take((int)Math.Ceiling(buyouts.Count() * percentile));
            result.Mean = culledBuyouts.Average();
            // Min of latest scan
            result.CurrMin = auctions.Where(a => a.TimeStamp == auctions.Select(ts => ts.TimeStamp).Max()).Select(auc => auc.Buyout / auc.Quanity).Min();

            Int64 sumOfDeviation = (Int64)Math.Floor(culledBuyouts.Sum(d => (d - result.Mean) * (d - result.Mean)));
            result.StdDev = Math.Sqrt(sumOfDeviation / culledBuyouts.Count());

            result.ZValue = (result.CurrMin - result.Mean) / result.StdDev;

            return result;
        }