Ejemplo n.º 1
0
        public void TestInit()
        {
            _container = new UnityAutoMoqContainer();

            _container.RegisterType <ICsvMapping <IncrementalClaimData>, CsvIncrementalClaimDataMapping>();
            _sut = _container.Resolve <IncrementalDataFileParser>();
        }
        public async Task Process_DataHas1990AsEarliestDevelopmentYear_CanFind()
        {
            // arrange
            _container
            .GetMock <IConfig>()
            .Setup(x => x.IncrementalDataFilePath)
            .Returns(Path.GetFullPath("IncrementalClaimData.csv"));

            var incrementalDataFileParser = _container.Resolve <IIncrementalDataFileParser>();
            var incrementalClaims         = await incrementalDataFileParser.Parse();

            // act
            var claimData = await _sut.Process(incrementalClaims);

            // assert
            var expected = new Year("1990");

            claimData.EarliestOriginalYear
            .AsSource()
            .OfLikeness <Year>()
            .ShouldEqual(expected);
        }
        public void Save_WhenThereIsNodeToSave_VerifySaveMethodHasbeenCalledOnce()
        {
            //With standard Moq.Mock you do this..
            //var notesManagerViewStub = new Mock<INotesManagerView>();
            //var notesManagerServiceMock = new Mock<INotesManagerService>();
            //notesManagerViewStub.SetupGet(x => x.NoteToAdd).Returns(new NoteViewModel());
            //_sut = new NotesManagerPresenter(notesManagerViewStub.Object, notesManagerServiceMock.Object);

            //With UnityMoq you don't have to worry about addtional stub. It just works for you!
            var notesManagerServiceMock = _autoMoqContainer.GetMock <INotesManagerService>();

            _sut = _autoMoqContainer.Resolve <NotesManagerPresenter>();

            _sut.Save();

            notesManagerServiceMock.Verify(x => x.Save(It.IsAny <Note>()), Times.Once());
        }
Ejemplo n.º 4
0
        private static IVotingProcessService GetScrutinService()
        {
            var container = new UnityAutoMoqContainer();

            container.RegisterType <IVotingProcessService, ScrutinService>();
            container.RegisterType <ICalculateurFactory, CalculatorFactory>();
            container.RegisterType <IMapperService, MapperService>();

            var repoMock = container.GetMock <IVotingProcessRepository>();

            repoMock.Setup(m => m.GetVotingProcess())
            .Returns(ScrutinsParNom.Values.AsQueryable());

            var resultatRepoMock = container.GetMock <IRepository <Result> >();

            resultatRepoMock.Setup(m => m.Add(It.IsAny <Result>()))
            .Callback((Result resultat) => ScenarioContext.Current["ResultatBdd"] = resultat);

            resultatRepoMock.Setup(r => r.GetAll("", null))
            .Returns(() => new[] { ScenarioContext.Current["ResultatBdd"] as Result }.AsQueryable());

            return(container.Resolve <IVotingProcessService>());
        }
        public void Can_get_instance_without_registering_it_first()
        {
            var mocked = container.Resolve <IService>();

            mocked.ShouldNotBeNull();
        }
        public void Can_get_instance_without_registering_it_first()
        {
            var mocked = _container.Resolve <IService>();

            Assert.IsNotNull(mocked);
        }