public void TestTraceDataDoesNotLogToLogglyWhenLoggerIsNull() { this._targetListener.Logger = null; this._targetListener.TraceData(null, null, GetRandom.Enumeration <TraceEventType>(), 0, null); this._mockLogger.DidNotReceive().Log(Arg.Any <string>()); }
public void TestTraceDataLogsEmptyMessageToLogglyForNullDataWhenTraceFilterIsNull() { this._targetListener.Filter = null; this._targetListener.TraceData(null, null, GetRandom.Enumeration <TraceEventType>(), 0, (object)null); this._mockLogger.Received().Log(string.Empty); }
public void TestTraceDataDoesNotLogToLogglyWhenEventTypeDoesNotMatchTraceFilter() { this._targetListener.Filter = new EventTypeFilter(SourceLevels.Off); this._targetListener.TraceData(null, null, GetRandom.Enumeration <TraceEventType>(), 0, null); this._mockLogger.DidNotReceive().Log(Arg.Any <string>()); }
public void TestTraceDataLogsEmptyMessageToLogglyForNullDataWhenSourceMatchesTraceFilter() { var expectedSource = GetRandom.String(10); this._targetListener.Filter = new SourceFilter(expectedSource); this._targetListener.TraceData(null, expectedSource, GetRandom.Enumeration <TraceEventType>(), 0, (object)null); this._mockLogger.Received().Log(string.Empty); }
public void TestTraceDataLogsExpectedMessageToLogglyForNonLogEntryDataWhenFormatterIsNull() { var expectedData = new object(); var expectedMessage = expectedData.ToString(); this._targetListener.TraceData(null, null, GetRandom.Enumeration <TraceEventType>(), 0, expectedData); this._mockLogger.Received().Log(expectedMessage); }
public void TestTraceDataDoesNotLogToLogglyWhenSourceDoesNotMatchTraceFilter() { var expectedSource = GetRandom.String(10); this._targetListener.Filter = new SourceFilter(string.Empty); this._targetListener.TraceData(null, expectedSource, GetRandom.Enumeration <TraceEventType>(), 0, null); this._mockLogger.DidNotReceive().Log(Arg.Any <string>()); }
public void TestTraceDataLogsExpectedMessageToLogglyForNonLogEntryDataWhenEventTypeMatchesTraceFilter() { var expectedData = new object(); var expectedMessage = expectedData.ToString(); this._targetListener.Filter = new EventTypeFilter(SourceLevels.All); this._targetListener.TraceData(null, null, GetRandom.Enumeration <TraceEventType>(), 0, expectedData); this._mockLogger.Received().Log(expectedMessage); }
public void GenerateRandomEnumUsingType_ShouldIncludeAllEnumValues() { var expected = Enum.GetValues(typeof(StatusType)).Cast <StatusType>().ToList(); var actual = new List <Enum>(); for (var i = 0; i < 100000; i++) { var statusType = GetRandom.Enumeration(typeof(StatusType)); actual.Add(statusType); } expected.ShouldAllBe(e => actual.Contains(e)); }
public void TestTraceDataLogsExpectedFormattedLogEntryToLogglyWhenTraceFilterIsNull() { var expectedFormattedLogEntry = GetRandom.String(10); var expectedLogEntry = Builder <LogEntry> .CreateNew().Build(); this._mockLogFormatter.Format(expectedLogEntry).Returns(expectedFormattedLogEntry); this._targetListener.Filter = null; this._targetListener.TraceData(null, null, GetRandom.Enumeration <TraceEventType>(), 0, expectedLogEntry); this._mockLogger.Received().Log(expectedFormattedLogEntry); }
public async Task WHEN_Passing_Empty_Parameter_SHOULD_Return_Empty_ViewModel() { var inventoryRepository = new Mock <IInventoryRepository>(); inventoryRepository.Setup(i => i.FindInventoryItemStatus(It.IsAny <FindInventoryItemStatusParam>())) .ReturnsAsync(new List <InventoryItemAvailability> { new InventoryItemAvailability { Date = DateTime.MinValue, Identifier = new InventoryItemIdentifier { InventoryLocationId = string.Empty, Sku = string.Empty }, Statuses = new List <InventoryItemStatus> { new InventoryItemStatus { Quantity = null, Status = GetRandom.Enumeration <InventoryStatus>() } } } }); var viewModelMapper = FakeViewModelMapper.CreateFake(typeof(InventoryViewService).Assembly); var inventoryViewService = new InventoryViewService(inventoryRepository.Object, viewModelMapper); var viewModel = await inventoryViewService.FindInventoryItemStatus(new FindInventoryItemStatusParam { Scope = string.Empty, Date = DateTime.MinValue, CultureInfo = new CultureInfo("en-CA"), Skus = new List <string> { string.Empty } }).ConfigureAwait(false); Assert.IsNotNull(viewModel); Assert.That(viewModel.Count == 1); Assert.That(viewModel[0].Date == DateTime.MinValue); Assert.That(viewModel[0].Identifier.InventoryLocationId == string.Empty); Assert.That(viewModel[0].Identifier.Sku == string.Empty); Assert.That(viewModel[0].Statuses.Count == 1); Assert.That(viewModel[0].Statuses[0].Quantity == null); }
internal static Coupon CreateInvalidCoupon() { var coupon = new Coupon() { CouponCode = GetRandom.UpperCaseString(8), CouponState = InvalidCouponStates[GetRandom.Int(0, InvalidCouponStates.Length - 1)], DisplayText = GetRandom.Phrase(20), Id = GetRandom.Guid(), PromotionId = GetRandom.Guid(), HasBeenConsumed = GetRandom.Boolean(), IsActive = GetRandom.Boolean(), IsDeleted = GetRandom.Boolean(), Mode = GetRandom.Enumeration <CouponMode>() }; return(coupon); }
public void SetUp() { _container = new AutoMocker(); var repoMock = _container.GetMock <IPaymentRepository>(); repoMock.Setup(repo => repo.UpdatePaymentMethodAsync(It.IsNotNull <UpdatePaymentMethodParam>())) .Returns((UpdatePaymentMethodParam p) => { var cart = new ProcessedCart { Name = p.CartName, CultureName = p.CultureInfo.Name, ScopeId = p.Scope, CustomerId = p.CustomerId, Payments = new List <Payment> { new Payment { Id = p.PaymentId, PaymentMethod = new PaymentMethod { Id = p.PaymentMethodId, PaymentProviderName = p.PaymentProviderName, Type = GetRandom.Enumeration <PaymentMethodType>(), DisplayName = new LocalizedString { { p.CultureInfo.Name, GetRandom.String(12) } }, Enabled = true, Default = GetRandom.Boolean(), }, PaymentStatus = PaymentStatus.New } } }; return(Task.FromResult(cart)); }).Verifiable("The repository was not called to Update the payment method."); repoMock.Setup(repo => repo.InitializePaymentAsync(It.IsNotNull <InitializePaymentParam>())) .Returns((InitializePaymentParam p) => { var cart = new Overture.ServiceModel.Orders.Cart { Name = p.CartName, CultureName = p.CultureInfo.Name, ScopeId = p.Scope, CustomerId = p.CustomerId, Payments = new List <Payment> { new Payment { Id = p.PaymentId, PaymentMethod = new PaymentMethod { Id = p.PaymentId, PaymentProviderName = GetRandom.String(12), Type = GetRandom.Enumeration <PaymentMethodType>(), DisplayName = new LocalizedString { { p.CultureInfo.Name, GetRandom.String(12) } }, Enabled = true, Default = GetRandom.Boolean(), PropertyBag = new PropertyBag { //TODO: Change this to reflect real return from OV. { "HostedCardTokenizationUrl", string.Format("https://{0}/?id={1}&css={2}", GetRandom.WwwUrl(), GetRandom.String(16), GetRandom.String(255)) } } }, PaymentStatus = PaymentStatus.New } } }; return(Task.FromResult(cart)); }).Verifiable("The repository was not called to initialize the Payment."); var vmMapperMock = _container.GetMock <IViewModelMapper>(); vmMapperMock.Setup( vmm => vmm.MapTo <ActivePaymentViewModel>(It.IsNotNull <Payment>(), It.IsNotNull <CultureInfo>())) .Returns((Payment p, CultureInfo ci) => { var vm = new ActivePaymentViewModel { Id = p.Id, PaymentStatus = p.PaymentStatus }; return(vm); }).Verifiable("The ViewModelMapper has not been called to create an ActivePaymentViewModel."); }