public void Init()
 {
     _fixture = new Fixture().Customize(new AutoRhinoMockCustomization());
     _storage = _fixture.Create<IStateStorage>();
     _accessorFactory = _fixture.Create<IStateAccessorFactory>();
     _sut = new StateService(_storage);
 }
Esempio n. 2
0
 private MainViewModel CreateMainViewModel(IFixture fixture, IMessenger messenger = null)
 {
     var channel = fixture.Create<IChannel<SaveCmdApplicationConfigurationCommand>>();
     fixture.Register<ICmdApplicationConfigurationViewModelFactory>(() => fixture.Create<CmdApplicationConfigurationViewModelFactory>());
     fixture.Inject(messenger ?? new Messenger());
     return fixture.Build<MainViewModel>().OmitAutoProperties().Create();
 }
 public void SetUp()
 {
     _fixture = new Fixture().Customize(new AutoMoqCustomization());
     _surveyAppRepository = _fixture.Freeze<Mock<ISurveyRepository>>();
     _sut = _fixture.Create<SurveyAppService>();
     _expected = _fixture.Create<SoundConnect.Survey.Core.Entities.Survey>();
 }
 public void Customize(IFixture fixture)
 {
     fixture.Register(() => new TestIndexUtils(
         this.settings?? fixture.Create<ISettingsProvider>(), 
         fixture.Create<ISystemContext>(), 
         this.requestConfig));
 }
Esempio n. 5
0
 public void Init()
 {
     fixture = new Fixture();
     credentials = fixture.Create<ClientCredentials>();
     serverUri = fixture.Create<Uri>().ToString();
     classUnderTests = fixture.Create<ClientFactory>();
 }
 public MessageProcessingAsyncWrapper()
 {
     _fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
     ReceiveMessages = _fixture.Create<IReceiveMessagesFactory>();
     MessageContextFactory = _fixture.Create<IMessageContextFactory>();
     _fixture.Inject(ReceiveMessages);
     _fixture.Inject(MessageContextFactory);
 }
Esempio n. 7
0
 public static DirectoryInfo CreateWithContent(this DirectoryInfo info, IFixture fixture)
 {
     info.Create();
     var path = Path.Combine(info.FullName, fixture.Create<string>());
     using (var sw = new StreamWriter(new FileInfo(path).Open(FileMode.Create)))
         sw.WriteLine(fixture.Create<string>());
     return info;
 }
 public void Customize(IFixture fixture)
 {
     fixture.Register(() =>
             new ElasticLease(
                 fixture.Create<Guid>(), 
                 DateTime.UtcNow + this.expiresIn, 
                 fixture.Create<ElasticLeaseOwner>()));
 }
        public void Init()
        {
            _fixture = new Fixture().Customize(new AutoRhinoMockCustomization());
            _storage = _fixture.Create<IStateStorage>();
            _target = _fixture.Create<object>();
            var targetIdentity = RuntimeHelpers.GetHashCode(_target);
            _storage.Stub(x => x.GetStorage(targetIdentity)).Return(new Dictionary<string, object>());

            _sut = new StateAccessor(_target, _storage);
        }
        public void Init()
        {
            _fixture = new Fixture().Customize(new AutoRhinoMockCustomization());
            _sut = MockRepository.GeneratePartialMock<ComponentInfoHandler>();

            _currentAssembly = _fixture.Create<Assembly>();
            _sut.Stub(x => x.GetComponentAssembly()).Return(_currentAssembly);

            _question = _fixture.Create<IThermometerQuestion>();
            _question.Stub(x => x.RequestUri).Return(new Uri("http://servername:8888/xxx/yyy?a=b&c=d"));
        }
 public MessageProcessingWrapper()
 {
     _fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
     ReceiveMessages = _fixture.Create<IReceiveMessages>();
     var factory = _fixture.Create<IReceiveMessagesFactory>();
     factory.Create().ReturnsForAnyArgs(ReceiveMessages);
     _fixture.Inject(factory);
     MessageContextFactory = _fixture.Create<IMessageContextFactory>();
     _fixture.Inject(ReceiveMessages);
     _fixture.Inject(MessageContextFactory);
 }
        public void Setup()
        {
            _fixture = new Fixture()
                  .Customize(new AutoMoqCustomization())
                  .Customize(new MultipleCustomization());

            _cache = new Dictionary<string, RandomObject>();
            _baseAddress = _fixture.Create<string>();
            _uri = _fixture.Create<string>();

            _sut = _fixture.Create<HttpCachingService>();
        }
        public void Init()
        {
            _fixture = new Fixture().Customize(new AutoRhinoMockCustomization());
            _concreteStarter = _fixture.Create<IThermometerStarter>();
            _disposible = _fixture.Create<IDisposable>();

            var tcs = new TaskCompletionSource<IDisposable>();
            tcs.SetResult(_disposible);
            _disposibleTask = tcs.Task;

            _concreteStarter.Stub(x => x.Start()).Return(_disposible);
            _concreteStarter.Stub(x => x.StartAsync()).Return(_disposibleTask);
        }
        public void Setup()
        {
            _fixture = new Fixture()
                  .Customize(new AutoMoqCustomization())
                  .Customize(new MultipleCustomization());

            _httpService = _fixture.Freeze<Mock<IHttpService>>();
            _httpCachingService = _fixture.Freeze<Mock<IHttpCachingService>>();

            _baseAddress = _fixture.Create<string>();
            _uri = _fixture.Create<string>();
            _headers = _fixture.Create<Dictionary<string, string>>();

            _sut = _fixture.Create<HttpAsyncClient>();
        }
Esempio n. 15
0
        public GraphSearchTestFixture()
        {
            fixture = new Fixture().Customize(new AutoMoqCustomization());

            problem = fixture.Create<Mock<IProblem<TestState>>>();
            strategy = fixture.Create<Mock<IFringeStrategy<TestState>>>();

            startState = fixture.Create<TestState>();
            goalState = fixture.Create<TestState>();

            strategy.Setup(strat => strat.IsEmpty()).Returns(false);

            problem.Setup(prob => prob.GetStartingState()).Returns(startState);
            problem.Setup(prob => prob.IsGoalState(It.IsAny<TestState>())).Returns(false);
            problem.Setup(prob => prob.IsGoalState(goalState)).Returns(true);
        }
Esempio n. 16
0
        public void Init()
        {
            fixture = new Fixture().Customize(new AutoMoqCustomization());

            mockTurnHandler = fixture.Create<Mock<ITurnHandler>>();
            game = new Game(mockTurnHandler.Object, PlayerFactory.BuildPlayers(PLAYER_COUNT)); 
        }
 public void ConstructWithNullLoggerThrows(
     IFixture fixture)
 {
     fixture.Inject<ILogger>(null);
     var e = Assert.Throws<TargetInvocationException>(() => fixture.Create<NotifyErrorAttribute>());
     Assert.IsType<ArgumentNullException>(e.InnerException);
 }
        public void For_ReturnsCombinationOfDepthAndMemberTypesStrings(
            [Frozen] IGetDepthString getDepthString,
            [Frozen] IGetMemberTypesString getMemberTypesString,
            DefaultGetNodeString sut,
            string depthString,
            string memberTypesString,
            int depth,
            IFixture fixture)
        {
            // Arrange
            fixture.MakeNonRecursive();

            var graphNode = fixture.Create<GraphNode>();

            getDepthString.For(depth).Returns(depthString);
            getMemberTypesString.For(graphNode).Returns(memberTypesString);

            var expectedResult = depthString + memberTypesString;

            // Act
            var result = sut.For(graphNode, depth);

            // Assert
            Assert.Equal(expectedResult, result);
        }
 public void Customize(IFixture fixture)
 {
     fixture.Customize<JournaledEvent>(composer => composer
         .FromFactory(() => JournaledEvent.Create(
             new object(),
             (_, type, writer) => writer.WriteLine(fixture.Create("EventPayload")))));
 }
Esempio n. 20
0
        public void InitializeBase()
        {
            Fixture = new Fixture();
            CustomizeFixture(Fixture);

            Now = Fixture.Create<DateTimeOffset>();
        }
        public void Customize(IFixture fixture)
        {
            fixture.Register<ElasticContact>(
                () =>
                    {
                        var contact = new ElasticContact(
                            Guid.NewGuid(),
                            new ElasticContactIdentification(
                                this._idLevel == IdentificationLevel.Known ? fixture.Create<string>("tester") : null,
                                AuthenticationLevel.None,
                                this._idLevel));

                        contact.Metadata.Add(
                            new JProperty("System", 
                                new JObject(
                                    new JProperty("Classification", 1),
                                    new JProperty("OverrideClassification", 2),
                                    new JProperty("VisitCount", 101),
                                    new JProperty("Value", 10),
                                    new JProperty("IntegrationId", Guid.NewGuid()),
                                    new JProperty("AuthenticationLevel", 0))));

                        return contact;
                    });
        }
Esempio n. 22
0
        public void Setup()
        {
            _autofixture = new Fixture();
              new RenderingContextCustomisation().Customize(_autofixture);

              _context = _autofixture.Create<RenderingContext>();
        }
        public void Init()
        {
            fixture = new Fixture().Customize(new AutoMoqCustomization());
            ninject = new StandardKernel(new BindingsModule());

            mockChanceDeck = fixture.Create<Mock<Deck>>();
            mockChestDeck = fixture.Create<Mock<Deck>>();

            mockDeckFactory = fixture.Create<Mock<DeckFactory>>();
            mockDeckFactory.Setup(x => x.BuildChanceDeck()).Returns(mockChanceDeck.Object);
            mockDeckFactory.Setup(x => x.BuildCommunitiyChestDeck()).Returns(mockChestDeck.Object);

            ninject.Rebind<IDeckFactory>().ToConstant(mockDeckFactory.Object).InSingletonScope();

            cardHandler = ninject.Get<CardHandler>();
        }
        public void SetUp()
        {
            _fixture = new Fixture().Customize(new AutoMoqCustomization());
            _logger = _fixture.Freeze<Mock<ILogger>>();
            _sut = _fixture.Create<EmailSenderAppService>();

            CreateFolderForTest(); 
        }
        public void Initialize()
        {
            fixture = new Fixture();

            commandQueueName = fixture.Create<string>();
            eventQueueName = fixture.Create<string>();

            mockLoggerFactory = new Mock<ILoggerFactory>();
            mockLogger = new Mock<ILogger>();

            mockLoggerFactory.Setup(p => p.CreateLogger(It.IsAny<string>())).Returns(() => mockLogger.Object);

            mockContextManager = new Mock<IContextManager>();

            mockCommandErrorStrategy = new Mock<IErrorStrategy>();
            mockCommandQueueStrategy = new Mock<IQueueStrategy>();
            mockCommandServiceBus = new Mock<IServiceBus>();

            mockEventErrorStrategy = new Mock<IErrorStrategy>();
            mockEventQueueStrategy = new Mock<IQueueStrategy>();
            mockEventServiceBus = new Mock<IServiceBus>();
            
            mockServiceBusFactory = new Mock<IServiceBusFactory>();
            mockServiceBusFactory.Setup(p => p.CreateServiceBus(It.IsAny<MassTransitConnectionDescriptor>(), mockCommandQueueStrategy.Object, It.IsAny<IReadOnlyList<Action<SubscriptionBusServiceConfigurator>>>())).Returns(mockCommandServiceBus.Object);
            mockServiceBusFactory.Setup(p => p.CreateServiceBus(It.IsAny<MassTransitConnectionDescriptor>(), mockEventQueueStrategy.Object, It.IsAny<IReadOnlyList<Action<SubscriptionBusServiceConfigurator>>>())).Returns(mockEventServiceBus.Object);

            mockCommandQueueStrategy.Setup(p => p.GetQueueName()).Returns(commandQueueName);
            mockEventQueueStrategy.Setup(p => p.GetQueueName()).Returns(eventQueueName);

            options = new MassTransitOptions
            {
                LoggerFactory = mockLoggerFactory.Object,
                CommandErrorStrategy = mockCommandErrorStrategy.Object,
                CommandQueueStrategy = mockCommandQueueStrategy.Object,
                EventErrorStrategy = mockEventErrorStrategy.Object,
                EventQueueStrategy = mockEventQueueStrategy.Object,
                ServiceBusFactory = mockServiceBusFactory.Object,
                ContextManager = mockContextManager.Object
            };

            var host = fixture.Create<Uri>();
            var userName = fixture.Create<string>();
            var password = fixture.Create<string>();

            connectionDescriptor = new MassTransitConnectionDescriptor(host, userName, password);
        }
        public void Initialization()
        {
            fixture = new Fixture().Customize(new AutoMoqCustomization());

            budgetRepositoryMock = fixture.Freeze<Mock<IBudgetRepository>>();

            service = fixture.Create<ComptabiliteService>();
        }
 public void Init()
 {
     fixture = new Fixture();
     spanCollectorBuilder = MockRepository.GenerateStub<ISpanCollectorBuilder>();
     zipkinEndpoint = MockRepository.GenerateStub<ServiceEndpoint>();
     traceProvider = MockRepository.GenerateStub<ITraceProvider>();
     logger = MockRepository.GenerateStub<IMDLogger>();
     requestName = fixture.Create<string>();
 }
        public void Initialize()
        {
            _fixture = new Fixture().Customize(new AutoConfiguredMoqCustomization());
            _documentStoreMock = _fixture.Freeze<Mock<IDocumentStore>>();
            _documentSessionMock = _fixture.Freeze<Mock<IDocumentSession>>();
            _logMock = _fixture.Freeze<Mock<ILog>>();

            _document = _fixture.Create<IDocument>();
        }
        public void Customize(IFixture fixture)
        {
            var db = fixture.Create<DataContext>();
            var wrapper = new DataContextWrapper(db);
            fixture.Register<IDataContextWrapper>(() => wrapper);

            var scopeFactory = new DataContextScopeFactory(wrapper);
            fixture.Register<IDataContextScopeFactory>(() => scopeFactory);
        }
 void ICustomization.Customize(IFixture fixture)
 {
     fixture.Register(() => new IdentifierTag(Guid.NewGuid().ToString("N")));
     fixture.Register<IReadOnlyList<string>>(fixture.Create<string[]>);
     fixture.Register<IReadOnlyList<CloudFlareError>>(fixture.Create<CloudFlareError[]>);
     fixture.Register<IReadOnlyList<Zone>>(fixture.Create<Zone[]>);
     fixture.Register<IReadOnlyList<DnsRecord>>(fixture.Create<DnsRecord[]>);
     fixture.Register(() => JObject.FromObject(fixture.Create<CloudFlareResponseBase>()));
 }
Esempio n. 31
0
        public async Task DisplaySafetyCheckVM_VehicleRegistration_NotNull()
        {
            base.ClearAll();

            var displaySafetyCheckVM = _fixture.Create <DisplaySafetyCheckViewModel>();
            await displaySafetyCheckVM.Init();

            Assert.Equal("Vehicle: " + _latestSafetyCheck.VehicleSafetyCheck.VehicleRegistration, displaySafetyCheckVM.VehicleRegistration);
        }
Esempio n. 32
0
 public void Customize(IFixture fixture)
 {
     fixture.Register(() => LocalDate.FromDateTime(fixture.Create <DateTime>()));
 }
        public async Task PublishPendingEvents_sends_pending_events()
        {
            // Arrange
            var userId = Guid.NewGuid();

            var userCreated     = fixture.Create <FakeUserCreated>();
            var usernameChanged = fixture.Create <FakeUsernameChanged>();
            var domainEvents    = new DomainEvent[] { userCreated, usernameChanged };

            RaiseEvents(userId, domainEvents);

            var envelopes = new List <Envelope>(domainEvents.Select(e => new Envelope(e)));

            var batchOperation = new TableBatchOperation();

            envelopes
            .Select(e => PendingEventTableEntity.FromEnvelope <FakeUser>(e, serializer))
            .ForEach(batchOperation.Insert);
            await s_eventTable.ExecuteBatchAsync(batchOperation);

            batchOperation.Clear();
            envelopes
            .Select(e => EventTableEntity.FromEnvelope <FakeUser>(e, serializer))
            .ForEach(batchOperation.Insert);
            await s_eventTable.ExecuteBatchAsync(batchOperation);

            List <Envelope> batch = null;

            Mock.Get(messageBus)
            .Setup(
                x =>
                x.SendBatch(
                    It.IsAny <IEnumerable <Envelope> >(),
                    It.IsAny <CancellationToken>()))
            .Callback <IEnumerable <Envelope>, CancellationToken>((b, t) => batch = b.ToList())
            .Returns(Task.FromResult(true));

            // Act
            await sut.PublishPendingEvents <FakeUser>(userId, CancellationToken.None);

            // Assert
            Mock.Get(messageBus).Verify(
                x =>
                x.SendBatch(
                    It.IsAny <IEnumerable <Envelope> >(),
                    CancellationToken.None),
                Times.Once());
            batch.ShouldAllBeEquivalentTo(envelopes, opts => opts.RespectingRuntimeTypes());
        }
Esempio n. 34
0
        public async Task EvaluateFalse(
            [CombinatorialValues(PermissionId.Allow, PermissionId.AllowInherited)] int permissionId,
            [CombinatorialValues(
                 Permissions.ManagePermissions,
                 Permissions.BypassPoliciesCodePush,
                 Permissions.BypassPoliciesPullRequest)] int permissionBit)
        {
            // Arrange
            CustomizePermission(permissionId, permissionBit);

            // Act
            var rule   = new NobodyCanBypassPolicies(_fixture.Create <IVstsRestClient>());
            var result = await rule.EvaluateAsync(_fixture.Create <string>(), _fixture.Create <string>());

            // Assert
            result.ShouldBe(false);
        }
Esempio n. 35
0
        public void Customize(IFixture fixture)
        {
            var qty = fixture.Create <Generator <int> >().First(v => v > 0);

            fixture.Freeze <IStockService>().GetQuantity(Arg.Any <Guid>()).Returns(qty);
        }
Esempio n. 36
0
        public void Bill_ShouldChangeName()
        {
            var bill = CreateBill();
            var name = _fixture.Create <string>();

            bill.SetName(name);

            Assert.Equal(bill.Name, name);
        }