예제 #1
0
        public void NullContractInvalid()
        {
            // Arrange
            var validatorFactory = new Mock <IValidatorEngine>();
            var mappingEngine    = new Mock <IMappingEngine>();
            var repository       = new Mock <IRepository>();
            var searchCache      = new Mock <ISearchCache>();

            var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object);

            validatorFactory.Setup(x => x.IsValid(It.IsAny <object>(), It.IsAny <IList <IRule> >())).Returns(false);

            // Act
            service.Create(null);
        }
예제 #2
0
        public void ValidContractIsSaved()
        {
            // Arrange
            var validatorFactory = new Mock <IValidatorEngine>();
            var mappingEngine    = new Mock <IMappingEngine>();
            var repository       = new Mock <IRepository>();
            var searchCache      = new Mock <ISearchCache>();

            var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object);

            var curve    = new Curve();
            var contract = new MDM.Contracts.Curve();

            validatorFactory.Setup(x => x.IsValid(It.IsAny <MDM.Contracts.Curve>(), It.IsAny <IList <IRule> >())).Returns(true);
            mappingEngine.Setup(x => x.Map <MDM.Contracts.Curve, Curve>(contract)).Returns(curve);

            // Act
            var expected = service.Create(contract);

            // Assert
            Assert.AreSame(expected, curve, "Curve differs");
            repository.Verify(x => x.Add(curve));
            repository.Verify(x => x.Flush());
        }