public bool ComparePriceChecker(Prices expectedPrice, Prices testPrice) { Prices price = new Prices(); PropertyInfo[] arrayOfProperties = price.GetType().GetProperties(); foreach(var property in arrayOfProperties) { if (expectedPrice.GetType().GetProperty(property.Name) != testPrice.GetType().GetProperty(property.Name)) { return false; } } return true; }