예제 #1
0
        public void CreateDuplicateChildContainer_Data_Name()
        {
            EAV.Store.Clients.IContainerStoreClient client = factory.Create <EAV.Store.Clients.IContainerStoreClient>();
            int    parentContainerID = SelectRandomItem(this.DbContext.Containers.Where(it => it.Parent_Container_ID == null)).Container_ID;
            string containerName     = Guid.NewGuid().ToString();

            EAV.Store.IStoreContainer container = client.CreateChildContainer(new EAVStoreLibrary.StoreContainer()
            {
                Name        = containerName,
                DataName    = containerName.ToUpper(),
                DisplayText = containerName + ":",
                IsRepeating = true,
                Sequence    = rng.Next(),
            }, parentContainerID);

            Assert.IsNotNull(container, "Failed to create container with name '{0}' for parent container ID {1}.", containerName, parentContainerID);

            client.CreateChildContainer(new EAVStoreLibrary.StoreContainer()
            {
                Name        = containerName + "1",
                DataName    = containerName.ToUpper(),
                DisplayText = containerName + ":",
                IsRepeating = true,
                Sequence    = rng.Next(),
            }, parentContainerID);

            Assert.Fail("Failed to throw exception creating child container with duplicate name.");
        }
예제 #2
0
        public void CreateChildContainer()
        {
            EAV.Store.Clients.IContainerStoreClient client = factory.Create <EAV.Store.Clients.IContainerStoreClient>();
            int    parentContainerID = SelectRandomItem(this.DbContext.Containers.Where(it => it.Parent_Container_ID == null)).Container_ID;
            string containerName     = Guid.NewGuid().ToString();

            EAV.Store.IStoreContainer container = client.CreateChildContainer(new EAVStoreLibrary.StoreContainer()
            {
                Name        = containerName,
                DataName    = containerName.ToUpper(),
                DisplayText = containerName + ":",
                IsRepeating = true,
                Sequence    = rng.Next(),
            }, parentContainerID);

            Assert.IsNotNull(container, "Failed to create container with name '{0}' for parent container ID {1}.", containerName, parentContainerID);

            ResetDatabaseContext();

            var dbContainer = this.DbContext.Containers.SingleOrDefault(it => it.Container_ID == container.ContainerID);

            Assert.IsNotNull(dbContainer, String.Format("Failed to retrieve container ID {0} from the database.", container.ContainerID));

            Assert.IsNotNull(dbContainer.Parent_Container_ID, "Container has no parent reference defined when it should.");

            Assert.AreEqual(container.Name, dbContainer.Name, "Property 'Name' was not created correctly.");
            Assert.AreEqual(container.DataName, dbContainer.Data_Name, "Property 'DataName' was not created correctly.");
            Assert.AreEqual(container.DisplayText, dbContainer.Display_Text, "Property 'DisplayText' was not created correctly.");
            Assert.AreEqual(container.IsRepeating, dbContainer.Is_Repeating, "Property 'IsRepeating' was not created correctly.");
            Assert.AreEqual(container.Sequence, dbContainer.Sequence, "Property 'Sequence' was not created correctly.");
        }
예제 #3
0
 public IHttpActionResult CreateChildContainer(int id, EAV.Store.IStoreContainer container)
 {
     try
     {
         return(Ok <EAV.Store.IStoreContainer>(containerClient.CreateChildContainer(container, id)));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }