コード例 #1
0
        public void Constructor()
        {
            var saveService = new Mock <ISaveItemService <Uom> >().Object;
            var readService = new Mock <IReadItemService <Uom> >().Object;

            ConstructorTests <UomItemViewModel>
            .For(typeof(ISaveItemService <Uom>), typeof(IReadItemService <Uom>))
            .Fail(new object[] { null, readService }, typeof(ArgumentNullException), "Null saveService.")
            .Fail(new object[] { saveService, null }, typeof(ArgumentNullException), "Null readService.")
            .Succeed(new object[] { saveService, readService }, "Constructor args valid.")
            .Assert();
        }
コード例 #2
0
        public void Constructor()
        {
            var httpService  = new Mock <IHttpReadService>().Object;
            var deserializer = new Mock <IContentDeserializer>().Object;

            ConstructorTests <ReadPageServiceBuildRequest <Uom> >
            .For(typeof(IHttpReadService), typeof(IContentDeserializer))
            .Fail(new object[] { null, deserializer }, typeof(ArgumentNullException), "Null httpService")
            .Fail(new object[] { httpService, null }, typeof(ArgumentNullException), "Null deserializer")
            .Succeed(new object[] { httpService, deserializer }, "Constructor args valid.")
            .Assert();
        }
コード例 #3
0
        public void Constructor()
        {
            var acceptedMedia = new Mock <IAcceptedMediaSource>().Object;
            var next          = new Mock <IHttpService>().Object;

            ConstructorTests <HttpServiceAddAcceptHeader>
            .For(typeof(IAcceptedMediaSource), typeof(IHttpService))
            .Fail(new object[] { null, next }, typeof(ArgumentNullException), "Null acceptedMedia")
            .Fail(new object[] { acceptedMedia, null }, typeof(ArgumentNullException), "Null next")
            .Succeed(new object[] { acceptedMedia, next }, "Constructor args valid.")
            .Assert();
        }
コード例 #4
0
        public void Constructor()
        {
            var templateKey = "key";
            var lookup      = new Mock <ILinkTemplateLookup>().Object;

            ConstructorTests <ItemUrlBuilder <Uom> >
            .For(typeof(string), typeof(ILinkTemplateLookup))
            .Fail(new object[] { null, lookup }, typeof(ArgumentException), "Null templateKey")
            .Fail(new object[] { templateKey, null }, typeof(ArgumentNullException), "Null templateKey")
            .Succeed(new object[] { templateKey, lookup }, "Constructor args valid.")
            .Assert();
        }
コード例 #5
0
        public void Constructor()
        {
            var httpService = new Mock <IHttpWriteService>().Object;
            var serializer  = new Mock <IContentSerializer>().Object;

            ConstructorTests <SaveItemServiceBuildRequest <Uom> >
            .For(typeof(IHttpWriteService), typeof(IContentSerializer))
            .Fail(new object[] { null, serializer }, typeof(ArgumentNullException), "Null httpService.")
            .Fail(new object[] { httpService, null }, typeof(ArgumentNullException), "Null serializer.")
            .Succeed(new object[] { httpService, serializer }, "Constructor args valid.")
            .Assert();
        }
コード例 #6
0
        public void Constructor()
        {
            var validator = new Mock <IValidator>().Object;
            var next      = new Mock <ISaveItemService <Uom> >().Object;

            ConstructorTests <SaveItemServiceValidate <Uom> >
            .For(typeof(IValidator), typeof(ISaveItemService <Uom>))
            .Fail(new object[] { null, next }, typeof(ArgumentNullException), "Null validator")
            .Fail(new object[] { validator, null }, typeof(ArgumentNullException), "Null next")
            .Succeed(new object[] { validator, next }, "Constructor args valid.")
            .Assert();
        }
コード例 #7
0
        public void Contructor()
        {
            var readRepository   = new Mock <IReadRepository <TestEntity> >().Object;
            var pageLinksBuilder = new Mock <IPageLinksBuilder>().Object;

            ConstructorTests <ReadController <TestEntity> >
            .For(typeof(IReadRepository <TestEntity>), typeof(IPageLinksBuilder))
            .Fail(new object[] { readRepository, null }, typeof(ArgumentNullException), "Null PageLinksBuilder")
            .Fail(new object[] { null, pageLinksBuilder }, typeof(ArgumentNullException), "Null Respository")
            .Succeed(new object[] { readRepository, pageLinksBuilder }, "Constructor args valid")
            .Assert();
        }
        public void Constructor()
        {
            var urlBuilder = new Mock <IItemWriteUrlBuilder <Uom> >().Object;
            var next       = new Mock <IDeleteItemServiceBuildRequest>().Object;

            ConstructorTests <DeleteItemServiceBuildUrl <Uom> >
            .For(typeof(IItemWriteUrlBuilder <Uom>), typeof(IDeleteItemServiceBuildRequest))
            .Fail(new object[] { null, next }, typeof(ArgumentNullException), "Null urlBuilder.")
            .Fail(new object[] { urlBuilder, null }, typeof(ArgumentNullException), "Null next.")
            .Succeed(new object[] { urlBuilder, next }, "Constructor args valid.")
            .Assert();
        }
コード例 #9
0
        public void Contructor()
        {
            var urlBaseBuilder     = new Mock <IUrlBaseBuilder>().Object;
            var pageLinksFormatter = new Mock <IPageLinksFormatter>().Object;

            ConstructorTests <PageLinksBuilder>
            .For(typeof(IUrlBaseBuilder), typeof(IPageLinksFormatter))
            .Fail(new object[] { null, pageLinksFormatter }, typeof(ArgumentNullException), "Null UrlBaseBuilder")
            .Fail(new object[] { urlBaseBuilder, null }, typeof(ArgumentNullException), "Null PageLinksFormatter")
            .Succeed(new object[] { urlBaseBuilder, pageLinksFormatter }, "Constructor args valid")
            .Assert();
        }
コード例 #10
0
        public void Constructor()
        {
            var items = new Mock <IImmutableList <Uom> >().Object;
            var links = new PageLinksFormatter().GetLinks(Url, new Page <Uom>("", 40, 0, 10, new List <Uom>()));

            ConstructorTests <CollectionPageData <Uom> >
            .For(typeof(IImmutableList <Uom>), typeof(string))
            .Fail(new object[] { items, null }, typeof(ArgumentNullException), "Null links")
            .Fail(new object[] { null, links }, typeof(ArgumentNullException), "Null items")
            .Succeed(new object[] { items, links }, "Constructor args valid.")
            .Assert();
        }
コード例 #11
0
        public void Constructor()
        {
            var apiEndPoint        = new Mock <IEndPoint>().Object;
            var httpRequestBuilder = new Mock <IHttpRequestBuilder>().Object;
            var httpClient         = new Mock <IHttpReadClient>().Object;

            ConstructorTests <QTB3.Client.Common.Services.LinkService.LinkService>
            .For(typeof(IEndPoint), typeof(IHttpRequestBuilder), typeof(IHttpReadClient))
            .Fail(new object[] { null, httpRequestBuilder, httpClient }, typeof(ArgumentNullException), "apiEndpoint")
            .Fail(new object[] { apiEndPoint, null, httpClient }, typeof(ArgumentNullException), "httpRequestBuilder")
            .Fail(new object[] { apiEndPoint, httpRequestBuilder, null }, typeof(ArgumentNullException), "httpClient")
            .Succeed(new object[] { apiEndPoint, httpRequestBuilder, httpClient }, "Constructor args valid.")
            .Assert();
        }
コード例 #12
0
        public void Constructor()
        {
            var pageTitle       = "Home";
            var readPageService = new Mock <IReadPageService <Uom> >().Object;
            var newPageService  = new Mock <IReadPageServiceNewPage <Uom> >().Object;
            var deleteService   = new Mock <IDeleteItemService <Uom> >().Object;

            ConstructorTests <CollectionPageViewModel <Uom> >
            .For(typeof(string), typeof(IReadPageService <Uom>), typeof(IReadPageServiceNewPage <Uom>), typeof(IDeleteItemService <Uom>))
            .Fail(new object[] { string.Empty, readPageService, newPageService, deleteService }, typeof(ArgumentException), "Empty Title.")
            .Fail(new object[] { pageTitle, null, newPageService, deleteService }, typeof(ArgumentNullException), "Null readPageService.")
            .Fail(new object[] { pageTitle, readPageService, null, deleteService }, typeof(ArgumentNullException), "Null newPageService.")
            .Fail(new object[] { pageTitle, readPageService, newPageService, null }, typeof(ArgumentNullException), "Null deleteService.")
            .Succeed(new object[] { pageTitle, readPageService, newPageService, deleteService }, "Constructor args valid.")
            .Assert();
        }
コード例 #13
0
        public void Constructor()
        {
            var lrpNavigation     = new Mock <ILrpNavigation>().Object;
            var itemPageViewModel = new Mock <IItemViewModel <Uom> >().Object;
            var itemPage          = new Mock <IItemPage <Uom> >().Object;

            ConstructorTests <ItemPageController <Uom> >
            .For
            (
                typeof(ILrpNavigation),
                typeof(IItemViewModel <Uom>),
                typeof(IItemPage <Uom>)
            )
            .Fail(new object[] { null, itemPageViewModel, itemPage }, typeof(ArgumentNullException), "Null lrpNavigation.")
            .Fail(new object[] { lrpNavigation, null, itemPage }, typeof(ArgumentNullException), "Null itemViewModel")
            .Fail(new object[] { lrpNavigation, itemPageViewModel, null }, typeof(ArgumentNullException), "Null itemPage")
            .Succeed(new object[] { lrpNavigation, itemPageViewModel, itemPage }, "Constructor args valid")
            .Assert();
        }
コード例 #14
0
        public void Constructor()
        {
            var createItemViewModel      = new Mock <Func <IItemViewModel <Uom> > >().Object;
            var createItemPage           = new Mock <Func <IItemPage <Uom> > >().Object;
            var createItemPageController = new Mock <Func <ILrpNavigation, IItemViewModel <Uom>, IItemPage <Uom>, IItemPageController <Uom> > >().Object;

            ConstructorTests <ItemMvcBuilder <Uom> >
            .For
            (
                typeof(Func <IItemViewModel <Uom> >),
                typeof(Func <IItemPage <Uom> >),
                typeof(Func <ILrpNavigation, IItemViewModel <Uom>, IItemPage <Uom>, IItemPageController <Uom> >)
            )
            .Fail(new object[] { null, createItemPage, createItemPageController }, typeof(ArgumentNullException), "Null createItemViewModel.")
            .Fail(new object[] { createItemViewModel, null, createItemPageController }, typeof(ArgumentNullException), "Null createItemPage.")
            .Fail(new object[] { createItemViewModel, createItemPage, null }, typeof(ArgumentNullException), "Null createItemPageController.")
            .Succeed(new object[] { createItemViewModel, createItemPage, createItemPageController }, "Constructor args valid")
            .Assert();
        }
コード例 #15
0
        public void Constructor()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            try
            {
                using (var context = GetPropertyContext(connection))
                {
                    ConstructorTests <UomWriteRepository>
                    .For(typeof(PropertyContext))
                    .Fail(new object[] { null }, typeof(ArgumentNullException), "Null context")
                    .Succeed(new object[] { context }, "Constructor arguments valid")
                    .Assert();
                }
            }
            finally
            {
                connection.Close();
            }
        }
コード例 #16
0
        public void Constructor()
        {
            var lrpNavigation           = new Mock <ILrpNavigation>().Object;
            var collectionPageViewModel = new Mock <ICollectionPageViewModel <Uom> >().Object;
            var collectionPage          = new Mock <ICollectionPage <Uom> >().Object;
            var itemMvcBuilder          = new Mock <IItemMvcBuilder <Uom> >().Object;

            ConstructorTests <CollectionPageController <Uom> >
            .For
            (
                typeof(ILrpNavigation),
                typeof(ICollectionPageViewModel <Uom>),
                typeof(ICollectionPage <Uom>),
                typeof(IItemMvcBuilder <Uom>)
            )
            .Fail(new object[] { null, collectionPageViewModel, collectionPage, itemMvcBuilder }, typeof(ArgumentNullException), "Null lrpNavigation.")
            .Fail(new object[] { lrpNavigation, null, collectionPage, itemMvcBuilder }, typeof(ArgumentNullException), "Null collectionPageViewModel.")
            .Fail(new object[] { lrpNavigation, collectionPageViewModel, null, itemMvcBuilder }, typeof(ArgumentNullException), "Null collectionPage.")
            .Fail(new object[] { lrpNavigation, collectionPageViewModel, collectionPage, null, }, typeof(ArgumentNullException), "Null itemMvcBuilder.")
            .Succeed(new object[] { lrpNavigation, collectionPageViewModel, collectionPage, itemMvcBuilder }, "Constructor args valid")
            .Assert();
        }
コード例 #17
0
        private void TestFileModuleLiteralOrAbove(FileModuleLiteral node, Type type)
        {
            using (var ms = new MemoryStream())
            {
                using (var writer = new BuildXLWriter(false, ms, true, false))
                    using (var reader = new BuildXLReader(true, ms, true))
                    {
                        // Serialize
                        node.Serialize(writer);

                        // Copy for validation
                        byte[] firstPass = ms.ToArray();

                        // Reset the stream pointer to the start for deserializing
                        ms.Position = 0;

                        // Deserialize
                        DeserializationContext context = new DeserializationContext(null, reader, m_pathTable, node.LineMap);
                        var node2 = FileModuleLiteral.Read(reader, context.PathTable, GlobalModuleLiteral, ModuleRegistry);

                        Assert.NotNull(node2);

                        // Reset the stream pointer to the start for serializing
                        ms.Position = 0;

                        // Reserialize
                        node2.Serialize(writer);

                        // Copy for validation
                        byte[] secondPass = ms.ToArray();

                        // Compare byte arrays
                        Assert.Equal(firstPass, secondPass);

                        // Compare ASTs
                        ConstructorTests.ValidateEqual(null, type, node, node2, nameof(type), null);
                    }
            }
        }
コード例 #18
0
        public void Constructor()
        {
            var mainPage      = new Mock <IMainPage>().Object;
            var viewModel     = new Mock <IMainPageViewModel>().Object;
            var lrpNavigation = new Mock <ILrpNavigation>().Object;
            var uomMvcBuilder = new Mock <ICollectionMvcBuilder <Uom> >().Object;

            ConstructorTests <MainPageController>
            .For
            (
                typeof(IMainPage),
                typeof(IMainPageViewModel),
                typeof(ILrpNavigation),
                typeof(ICollectionMvcBuilder <Uom>)
            )
            .Fail(new object[] { null, viewModel, lrpNavigation, uomMvcBuilder }, typeof(ArgumentNullException), "Null mainPage.")
            .Fail(new object[] { mainPage, null, lrpNavigation, uomMvcBuilder }, typeof(ArgumentNullException), "Null viewModel.")
            .Fail(new object[] { mainPage, viewModel, null, uomMvcBuilder }, typeof(ArgumentNullException), "Null lrpNavigation.")
            .Fail(new object[] { mainPage, viewModel, lrpNavigation, null }, typeof(ArgumentNullException), "Null uomMvcBuilder.")
            .Succeed(new object[] { mainPage, viewModel, lrpNavigation, uomMvcBuilder }, "Constructor args valid")
            .Assert();
        }
コード例 #19
0
        public void Constructor()
        {
            var mainPage        = new Mock <IMainPage>().Object;
            var jwtTokenManager = new Mock <IJwtTokenManager>().Object;
            var createLoginPage = new Mock <Func <ILoginPage> >().Object;
            var lrpNavigation   = new Mock <ILrpNavigation>().Object;

            ConstructorTests <LoginPageController>
            .For
            (
                typeof(IMainPage),
                typeof(IJwtTokenManager),
                typeof(Func <ILoginPage>),
                typeof(ILrpNavigation)
            )
            .Fail(new object[] { mainPage, jwtTokenManager, createLoginPage, null }, typeof(ArgumentNullException), "Null lrpNavigation.")
            .Fail(new object[] { mainPage, jwtTokenManager, null, lrpNavigation }, typeof(ArgumentNullException), "Null createLoginPage.")
            .Fail(new object[] { mainPage, null, createLoginPage, lrpNavigation }, typeof(ArgumentNullException), "Null jwtTokenManager.")
            .Fail(new object[] { null, jwtTokenManager, createLoginPage, lrpNavigation }, typeof(ArgumentNullException), "Null mainPage.")
            .Succeed(new object[] { mainPage, jwtTokenManager, createLoginPage, lrpNavigation }, "Constructor args valid")
            .Assert();
        }