예제 #1
0
        public void NetworkDeployedTest()
        {
            var mock  = _container.GetMock <IApplicationDeployment>();
            var mock2 = _container.GetMock <IApplicationContainer>();

            mock.SetupGet(s => s.IsNetworkDeployed).Returns(true);
            mock2.SetupAllProperties();

            var vm = new AboutViewModel(mock.Object, mock2.Object);

            Assert.IsTrue(vm.NetworkDeployed);
        }
        public void Should_apply_default_default_value_when_none_specified()
        {
            _container = new UnityAutoMoqContainer();
            var mocked = _container.GetMock <IService>();

            Assert.AreEqual(DefaultValue.Mock, mocked.DefaultValue);
        }
        public void Should_apply_specified_default_value_when_specified()
        {
            container = new UnityAutoMoqContainer(DefaultValue.Empty);
            var mocked = container.GetMock <IService>();

            mocked.DefaultValue.ShouldEqual(DefaultValue.Empty);
        }
        public void Should_apply_specified_default_value_when_specified_2()
        {
            _container = new UnityAutoMoqContainer {
                DefaultValue = DefaultValue.Empty
            };
            var mocked = _container.GetMock <IService>();

            Assert.AreEqual(DefaultValue.Empty, mocked.DefaultValue);
        }
        public void GetStubMethod_ShouldReturn_TheSameMockedInstance()
        {
            _container = new UnityAutoMoqContainer(DefaultValue.Empty);
            var mocked = _container.GetMock <IService>();

            var stub = _container.GetStub <IService>();

            Assert.AreSame(stub.Object, mocked.Object);
        }
        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);
        }
예제 #7
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 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());
        }
예제 #9
0
        public async Task Parse_ResolvesDependencies_ParsesTestFileInput()
        {
            // arrange
            _container
            .GetMock <IConfig>()
            .Setup(x => x.IncrementalDataFilePath)
            .Returns(Path.GetFullPath("IncrementalClaimData.csv"));

            // act
            var incrementalClaimDataList = await _sut.Parse();

            // assert
            var rowCount                 = 12;
            var productCount             = 2;
            var rowCountForAGivenProduct = 3;

            Assert.AreEqual(rowCount, incrementalClaimDataList.Count);
            Assert.AreEqual(productCount, incrementalClaimDataList.GroupBy(x => x.Product).Count());
            Assert.AreEqual(rowCountForAGivenProduct, incrementalClaimDataList.Count(x => x.Product == "Comp"));
            Assert.AreEqual(100, incrementalClaimDataList
                            .Single(x => x.Product == "Non-Comp" &&
                                    x.OriginalYear == new Year("1993") &&
                                    x.DevelopmentYear == new Year("1993")).Increment);
        }
        public void Should_apply_specified_default_value_when_specified_2()
        {
            container = new UnityAutoMoqContainer{DefaultValue = DefaultValue.Empty};
            var mocked = container.GetMock<IService>();

            mocked.DefaultValue.ShouldEqual(DefaultValue.Empty);
        }
        public void Should_apply_default_default_value_when_none_specified()
        {
            container = new UnityAutoMoqContainer();
            var mocked = container.GetMock<IService>();

            mocked.DefaultValue.ShouldEqual(DefaultValue.Mock);
        }
        public void GetStubMethod_ShouldReturn_TheSameMockedInstance()
        {
            container = new UnityAutoMoqContainer(DefaultValue.Empty);
            var mocked = container.GetMock<IService>();

            var stub = container.GetStub<IService>();

            mocked.Object.ShouldBeSameAs(stub.Object);
        }
 public static void some_operation_returns_1(SomeClassWithDependencies sut, UnityAutoMoqContainer container)
 {
     container.GetMock<ISomeOtherInterface>().Setup(x => x.SomeOperation()).Returns(1);
 }
        public void Can_get_mock()
        {
            Mock <IService> mock = container.GetMock <IService>();

            mock.ShouldNotBeNull();
        }
        public void Can_get_mock()
        {
            Mock <IService> mock = _container.GetMock <IService>();

            Assert.IsNotNull(mock);
        }