Esempio n. 1
0
 private void initializeTestData()
 {
     rate     = GetRandom.Decimal(1, 10);
     currency = new Currency(GetRandom.Object <CurrencyData>());
     rateType = new RateType(GetRandom.Object <RateTypeData>());
     date     = GetRandom.DateTime();
 }
        public void Decimal_returns_expected_Decimal_when_minValue_and_maxValue_are_same()
        {
            var expected = GetRandom.Decimal();
            var actual   = GetRandom.Decimal(expected, expected);

            actual.ShouldBe(expected);
        }
        public void SHOULD_convert_field()
        {
            // arrange
            var facet = new FacetImpl
            {
                Id          = GetRandom.Guid(),
                FieldName   = GetRandom.String(10),
                FacetType   = "SingleSelect",
                IsDisplayed = true,
                // StartValue = GetRandom.NumericString(2),
                // EndValue = GetRandom.NumericString(2),
                // GapSize = GetRandom.NumericString(2),
                MaxCollapsedValueCount = GetRandom.Int(),
                MaxExpendedValueCount  = GetRandom.Int(),
                SortWeight             = GetRandom.Decimal(),
            };

            // act
            var result = FacetsMapper.ConvertToFacetSetting(facet);

            // assert
            result.Should().NotBeNull();
            result.FieldName.Should().Be(facet.FieldName);
            result.FacetType.Should().Be(FacetType.SingleSelect);
            result.FacetValueType.Should().Be(typeof(string));
            result.IsDisplayed.Should().Be(facet.IsDisplayed);
            // result.StartValue.Should().Be(facet.StartValue);
            // result.EndValue.Should().Be(facet.EndValue);
            // result.GapSize.Should().Be(facet.GapSize);
            result.MaxCollapsedValueCount.Should().Be(facet.MaxCollapsedValueCount);
            result.MaxExpendedValueCount.Should().Be(facet.MaxExpendedValueCount);
            result.SortWeight.Should().Be((double)facet.SortWeight);
        }
Esempio n. 4
0
        public void IsNotEqualTest()
        {
            var s = GetRandom.Decimal();

            Assert.IsTrue(Obj.IsNotEqual(s));
            Assert.IsFalse(Obj.IsNotEqual(Obj.Value));
        }
Esempio n. 5
0
        public void IsNotGreaterTest()
        {
            var s = Obj.Value - GetRandom.Decimal(0, 100);

            Assert.IsFalse(Obj.IsNotGreater(s));
            Assert.IsTrue(Obj.IsNotGreater(Obj.Value));
        }
Esempio n. 6
0
 protected override void SetRandomValues()
 {
     base.SetRandomValues();
     productId   = GetRandom.String();
     description = GetRandom.String();
     amount      = GetRandom.Decimal();
 }
Esempio n. 7
0
        [TestMethod] public void ToDecimalTest()
        {
            var m = GetRandom.Decimal();
            var d = GetRandom.Double(Convert.ToSingle(decimal.MinValue),
                                     Convert.ToSingle(decimal.MaxValue));
            var f = GetRandom.Float(Convert.ToSingle(decimal.MinValue),
                                    Convert.ToSingle(decimal.MaxValue));
            var l  = GetRandom.Int64();
            var i  = GetRandom.Int32();
            var s  = GetRandom.Int16();
            var b  = GetRandom.Int8();
            var ul = GetRandom.UInt64();
            var ui = GetRandom.UInt32();
            var us = GetRandom.UInt16();
            var ub = GetRandom.UInt8();

            Assert.AreEqual(m, Decimals.ToDecimal(m));
            Assert.AreEqual(Convert.ToDecimal(d), Decimals.ToDecimal(d));
            Assert.AreEqual(Convert.ToDecimal(f), Decimals.ToDecimal(f));
            Assert.AreEqual(Convert.ToDecimal(l), Decimals.ToDecimal(l));
            Assert.AreEqual(Convert.ToDecimal(i), Decimals.ToDecimal(i));
            Assert.AreEqual(Convert.ToDecimal(s), Decimals.ToDecimal(s));
            Assert.AreEqual(Convert.ToDecimal(b), Decimals.ToDecimal(b));
            Assert.AreEqual(Convert.ToDecimal(ul), Decimals.ToDecimal(ul));
            Assert.AreEqual(Convert.ToDecimal(ui), Decimals.ToDecimal(ui));
            Assert.AreEqual(Convert.ToDecimal(us), Decimals.ToDecimal(us));
            Assert.AreEqual(Convert.ToDecimal(ub), Decimals.ToDecimal(ub));
            Assert.AreEqual(1.2345M, Decimals.ToDecimal("1.2345"));
            Assert.AreEqual(1.2345M, Decimals.ToDecimal(1.2345D));
            Assert.AreEqual(1.2345M, Decimals.ToDecimal(1.2345F));
        }
Esempio n. 8
0
 protected override void setRandomValues(Account o)
 {
     o.Data.Balance = GetRandom.Decimal();
     o.Data.Status  = GetRandom.String();
     o.Data.Type    = GetRandom.String();
     base.setRandomValues(o);
 }
Esempio n. 9
0
        public void GetSubTotalTest()
        {
            obj.RemoveAllItems();
            var listOfObj = new List <CartData>
            {
                GetRandom.Object <CartData>(),
                GetRandom.Object <CartData>(),
                GetRandom.Object <CartData>()
            };
            var listOfPrices = new List <decimal>
            {
                GetRandom.Decimal(0, 100),
                GetRandom.Decimal(0, 100),
                GetRandom.Decimal(0, 100)
            };
            var listOfQuantities = new List <int>
            {
                GetRandom.UInt8(),
                GetRandom.UInt8(),
                GetRandom.UInt8()
            };
            decimal result = 0;

            for (var i = 0; i < 3; i++)
            {
                listOfObj[i].GoodsData.Price = listOfPrices[i].ToString();
                listOfObj[i].Quantity        = listOfQuantities[i];
                obj.Add(new CartItem(listOfObj[i]));
                result += listOfPrices[i] * listOfQuantities[i];
            }
            Assert.AreEqual(result, obj.GetSubTotal());
        }
Esempio n. 10
0
        public void SetUp()
        {
            //Arrange
            _container = new AutoMocker();

            _container.Use(ViewModelMapperFactory.Create());
            _container.Use(CartViewModelFactoryMock.Create());

            var cartRepoMock = _container.GetMock <ICartRepository>();

            cartRepoMock.Setup(repo => repo.CompleteCheckoutAsync(It.IsNotNull <CompleteCheckoutParam>()))
            .Returns((CompleteCheckoutParam p) =>
            {
                var order = new Overture.ServiceModel.Orders.Order
                {
                    Cart = new ProcessedCart()
                    {
                        Customer = new CustomerSummary()
                        {
                            Email = GetRandom.Email()
                        },
                        Shipments = new System.Collections.Generic.List <Shipment>()
                        {
                            new Shipment
                            {
                                Id        = GetRandom.Guid(),
                                LineItems = new System.Collections.Generic.List <LineItem>()
                                {
                                    new LineItem
                                    {
                                        Id               = GetRandom.Guid(),
                                        Sku              = GetRandom.String(10),
                                        CatalogId        = GetRandom.String(10),
                                        PlacedPrice      = GetRandom.Decimal(),
                                        PlacedQuantity   = GetRandom.Int(),
                                        Status           = GetRandom.String(5),
                                        Total            = GetRandom.Decimal(),
                                        KvaValues        = new Overture.ServiceModel.PropertyBag(),
                                        KvaDisplayValues = new Overture.ServiceModel.PropertyBag(),
                                        ProductSummary   = new CartProductSummary
                                        {
                                            Brand                   = null,
                                            DisplayName             = GetRandom.String(10),
                                            PrimaryParentCategoryId = GetRandom.String(10)
                                        }
                                    }
                                },
                                FulfillmentMethod = new FulfillmentMethod
                                {
                                    FulfillmentMethodType = FulfillmentMethodType.PickUp
                                }
                            }
                        }
                    },
                    OrderNumber = GetRandom.String(12)
                };

                return(Task.FromResult(order));
            });
        }
Esempio n. 11
0
 public void TestInitialize()
 {
     Type   = typeof(Decimals);
     _d1    = GetRandom.Decimal() / 2M;
     _d2    = GetRandom.Decimal() / 2M;
     _absD1 = System.Math.Abs(_d1);
 }
Esempio n. 12
0
 protected override void SetRandomValues()
 {
     base.SetRandomValues();
     name         = GetRandom.String();
     serialNumber = GetRandom.String();
     price        = GetRandom.Decimal();
 }
Esempio n. 13
0
        public void IsNotLessTest()
        {
            var s = Obj.Value + GetRandom.Decimal(0, 100);

            Assert.IsFalse(Obj.IsNotLess(s));
            Assert.IsTrue(Obj.IsNotLess(Obj.Value));
        }
Esempio n. 14
0
        protected override void Given()
        {
            base.Given();

            _dto = new ProductDto
            {
                Description     = GetRandom.String(255),
                Name            = GetRandom.String(50),
                Price           = GetRandom.Decimal(),
                CategoryId      = GetRandom.Id(),
                ProductStatusId = GetRandom.Id(),
            };

            _newModel = new Product
            {
                Id              = GetRandom.Id(),
                CategoryId      = _dto.CategoryId,
                ProductStatusId = _dto.ProductStatusId,
                Name            = _dto.Name,
                Description     = _dto.Description,
                Price           = _dto.Price,
            };

            GetMockFor <IProductRepository>()
            .Setup(x => x.AddAsync(It.IsAny <int>(), It.IsAny <Product>()))
            .Returns((int userId, Product model) => Task.FromResult(_newModel));
        }
 protected override void setRandomValues(RequestTransaction o)
 {
     o.Data.Amount      = GetRandom.Decimal();
     o.Data.Explanation = GetRandom.String();
     o.Data.Status      = GetRandom.Enum <TransactionStatus>();
     base.setRandomValues(o);
 }
Esempio n. 16
0
        public void TestProperty(Func <decimal> get, Action <decimal> set)
        {
            var s = GetRandom.Decimal();

            Assert.AreNotEqual(s, get());
            set(s);
            Assert.AreEqual(s, get());
        }
        protected override void When()
        {
            base.When();

            _model.Price    = GetRandom.Decimal();
            _model.Quantity = GetRandom.Int32();
            SUT.SaveChangesAsync(AdminUserId).Wait();
        }
Esempio n. 18
0
        public void ValueTests()
        {
            var d = GetRandom.Decimal();

            obj.Value = d;
            Assert.AreEqual(d, obj.Value);
            Assert.AreEqual(d.ToString(UseCulture.Invariant), obj.ValueAsString);
        }
        public void Decimal_returns_random_Decimal_less_than_maxValue()
        {
            var maxValue = GetRandom.Decimal();
            var actual   = GetRandom.Decimal(maxValue);

            actual.ShouldBeOfType <decimal>();
            actual.ShouldBeLessThanOrEqualTo(maxValue);
        }
Esempio n. 20
0
        public void ConvertTest()
        {
            var s  = GetRandom.Decimal();
            var s1 = Obj.Convert(s.ToString(UseCulture.Invariant));

            Assert.AreEqual(s.ToString(UseCulture.Invariant),
                            s1.ToString(UseCulture.Invariant));
        }
Esempio n. 21
0
 [TestMethod] public void IsNullTest()
 {
     Assert.IsTrue(Utils.IsNull(null));
     Assert.IsFalse(Utils.IsNull(GetRandom.String()));
     Assert.IsFalse(Utils.IsNull(GetRandom.Char()));
     Assert.IsFalse(Utils.IsNull(GetRandom.Decimal()));
     Assert.IsFalse(Utils.IsNull(new object()));
 }
Esempio n. 22
0
        public void WHEN_cart_has_lineItem_SHOULD_map_first_shipment_vm()
        {
            //Arrange
            Container.Use(ViewModelMapperFactory.CreateFake(typeof(LineItemDetailViewModel).Assembly));


            var lineItem = new LineItem
            {
                Quantity     = GetRandom.Int(),
                ProductId    = GetRandom.String(32),
                VariantId    = GetRandom.String(32),
                Id           = Guid.NewGuid(),
                Total        = GetRandom.Decimal(),
                DefaultPrice = GetRandom.PositiveDecimal(2000000),
                CurrentPrice = new decimal()
            };

            var param = new CreateListOfLineItemDetailViewModelParam()
            {
                Cart      = new ProcessedCart(),
                LineItems = new List <LineItem> {
                    lineItem
                },
                CultureInfo = new CultureInfo("en-CA"),
                ImageInfo   = new ProductImageInfo {
                    ImageUrls = new List <ProductMainImage>()
                },
                BaseUrl = "http://orckestra.com/"
            };


            var sut = Container.CreateInstance <LineItemViewModelFactory>();

            //Act
            var vm = sut.CreateViewModel(param);

            //Assert
            vm.Should().NotBeNullOrEmpty();
            vm.Should().HaveSameCount(param.LineItems);
            var collection = vm.ToList();

            for (int i = 0; i < collection.Count; i++)
            {
                var liVm = collection[i];

                liVm.Should().NotBeNull();
                liVm.Id.Should().Be(lineItem.Id);
                liVm.ProductId.Should().Be(lineItem.ProductId);
                liVm.VariantId.Should().Be(lineItem.VariantId);
                liVm.ListPrice.Should().NotBeNullOrWhiteSpace();
                liVm.DefaultListPrice.Should().NotBeNullOrWhiteSpace();
                liVm.Quantity.Should().Be(lineItem.Quantity);
                liVm.Total.Should().NotBeNullOrWhiteSpace();

                liVm.ProductSummary.Should().NotBeNull();
                liVm.ProductSummary.DisplayName.Should().Be(lineItem.ProductSummary.DisplayName);
            }
        }
Esempio n. 23
0
        public void ValueAsStringTests()
        {
            obj.ValueAsString = GetRandom.String();
            Assert.AreEqual(decimal.Zero, obj.Value);
            var d = GetRandom.Decimal();

            obj.ValueAsString = d.ToString(UseCulture.Invariant);
            Assert.AreEqual(d, obj.Value);
        }
        [TestMethod] public void ToDecimalVariableTest()
        {
            var name  = GetRandom.String();
            var value = GetRandom.Decimal();
            var a     = Operand.ToVariable(name, value) as DecimalVariable;

            Assert.AreEqual(name, a.Name);
            Assert.AreEqual(value, a.Value);
        }
        public void Decimal_returns_random_Decimal_between_minValue_and_maxValue()
        {
            var maxValue = GetRandom.Decimal();
            var minValue = GetRandom.Decimal(maxValue);
            var actual   = GetRandom.Decimal(minValue, maxValue);

            actual.ShouldBeGreaterThanOrEqualTo(minValue);
            actual.ShouldBeLessThanOrEqualTo(maxValue);
        }
 public static OrderItem Simple()
 {
     return(new OrderItem
     {
         Price = GetRandom.Decimal(1, 10),
         Product = ProductMother.Simple(),
         Quantity = GetRandom.Int32(1, 10)
     });
 }
        protected override void When()
        {
            base.When();

            _model.Description     = GetRandom.String(1, 255);
            _model.Name            = GetRandom.String(1, 50);
            _model.Price           = GetRandom.Decimal();
            _model.ProductStatusId = (int)ProductStatus.Ids.BackOrdered;
            SUT.SaveChangesAsync(AdminUserId).Wait();
        }
Esempio n. 28
0
 public static Product Simple()
 {
     return(new Product
     {
         Name = GetRandom.String(1, 50),
         Category = CategoryMother.Simple(),
         Description = GetRandom.String(1, 255),
         Price = GetRandom.Decimal(1, 10),
         ProductStatus = ProductStatusMother.Simple()
     });
 }
        protected virtual PromotedFacetValueSettingImpl CreatePromotedFacet()
        {
            var promoted = new PromotedFacetValueSettingImpl
            {
                Id         = Guid.NewGuid(),
                SortWeight = GetRandom.Decimal(),
                Title      = GetRandom.String(10),
            };

            return(promoted);
        }
Esempio n. 30
0
        private void initializeTestData()
        {
            var min = DateTime.Now.AddYears(-50);
            var max = DateTime.Now.AddYears(50);

            id        = GetRandom.String();
            productId = GetRandom.String();
            userId    = GetRandom.String();
            price     = GetRandom.Decimal();
            validFrom = GetRandom.DateTime(min, max);
            validTo   = GetRandom.DateTime(validFrom, max);
        }