示例#1
0
        public IMapping Guid(string field)
        {
            FuncProvider <Guid> provider = new FuncProvider <Guid>(() => System.Guid.NewGuid());

            listOfFields.Add(field, provider);

            return(this);
        }
示例#2
0
        public void TypeOfProvider()
        {
            Func <string> testFunction = () =>
            {
                return(string.Empty);
            };
            FuncProvider <string> provider = new FuncProvider <string>(testFunction);

            Assert.Equal(typeof(string), provider.TType);
            Assert.Equal(ProviderType.Func, provider.Type);
        }
示例#3
0
        public void StringFuncWithTType()
        {
            Func <string> testFunction = () =>
            {
                return(string.Empty);
            };

            FuncProvider <string> provider = new FuncProvider <string>(testFunction);

            Assert.Equal(testFunction, provider.DefinedFunc);
        }
示例#4
0
        public void ConstructorWithFuncProvider()
        {
            Func <string> testFunction = () =>
            {
                return(string.Empty);
            };

            IDataProvider provider = new FuncProvider <string>(testFunction);
            var           settings = new JsonFieldSettings("id", provider);

            Assert.Equal("id", settings.Fields);
            Assert.Equal(ProviderType.Func.ToString(), settings.Type);
        }
示例#5
0
        public void StringFuncWithDefinedFunc()
        {
            var counter = 0;

            Func <string> testFunction = () =>
            {
                counter++;
                return(string.Empty);
            };

            FuncProvider <string> provider = new FuncProvider <string>(testFunction);

            Assert.Equal(testFunction, provider.DefinedFunc);
        }
示例#6
0
        public void StringFuncWithMoveNext()
        {
            Func <string> testFunction = () =>
            {
                Assert.True(true, "Delegate function is called.");
                return(string.Empty);
            };

            FuncProvider <string> provider = new FuncProvider <string>(testFunction);

            provider.MoveNext(null);

            //Assert.Equal(string.Empty, provider.Current);
        }
示例#7
0
        public void StringFuncWithMoveNexMultipleTimes()
        {
            var counter = 0;

            Func <string> testFunction = () =>
            {
                counter++;
                return(string.Empty);
            };

            FuncProvider <string> provider = new FuncProvider <string>(testFunction);

            for (int i = 0; i < 10; i++)
            {
                provider.MoveNext(null);
            }

            Assert.Equal(10, counter);
        }
示例#8
0
 public FuncProviderTests()
 {
     this.funcFactoryMock = new Mock <IFunctionFactory>();
     this.resolutionRoot  = new Mock <IResolutionRoot>().Object;
     this.testee          = new FuncProvider(this.funcFactoryMock.Object, ctx => this.resolutionRoot);
 }
 public FuncProviderTests()
 {
     this.funcFactoryMock = new Mock<IFunctionFactory>();
     this.resolutionRoot = new Mock<IResolutionRoot>().Object;
     this.testee = new FuncProvider(this.funcFactoryMock.Object, ctx => this.resolutionRoot);
 }