コード例 #1
0
        public void UpsertPlanContainer_Existing_Plan_Container_Succeeds()
        {
            // Arrange
            Guid containerUId = Guid.NewGuid();

            ;
            PlanContainer container = new PlanContainer()
            {
                UId  = containerUId,
                Name = _containerPrefix + containerUId
            };
            DynamoDbDal dal = new DynamoDbDal
            {
                ContainerTable = _containerTable
            };

            // Act
            dal.UpsertPlanContainer(container);
            container.Description = "Modified";
            dal.UpsertPlanContainer(container);
            PlanContainer retContainer = dal.GetPlanContainerByUId(container.UId);

            // Assert
            Assert.AreEqual(container.UId, retContainer.UId);
            Assert.AreEqual(container.Name, retContainer.Name);
            Assert.AreEqual(container.Description, retContainer.Description);
        }
コード例 #2
0
        public void GetPlanContainerByAny_Existing_Plan_Container_Succeeds()
        {
            Guid          containerUId = Guid.NewGuid();
            PlanContainer container    = new PlanContainer()
            {
                UId  = containerUId,
                Name = _containerPrefix + containerUId
            };
            DynamoDbDal dal = new DynamoDbDal
            {
                ContainerTable = _containerTable
            };

            // Act
            dal.UpsertPlanContainer(container);
            var retContainers = dal.GetPlanContainerByAny(containerUId, null, null, null, null, null, null);

            // Assert
            Assert.IsTrue(retContainers.Count > 0);
            foreach (PlanContainer c in retContainers)
            {
                Assert.AreEqual(c.UId, container.UId);
                Assert.AreEqual(c.Name, container.Name);
            }
        }
コード例 #3
0
        public void UpsertPlanContainer_Null_Plan_Container_Throws_Exception()
        {
            // Arrange
            PlanContainer container = null;
            DynamoDbDal   dal       = new DynamoDbDal
            {
                ContainerTable = _containerTable
            };

            // Act
            Exception ex = Assert.Throws <Exception>(() => dal.UpsertPlanContainer(container));

            // Assert
            StringAssert.AreEqualIgnoringCase("Plan container cannot be null.", ex.Message);
        }
コード例 #4
0
        public void UpsertPlanContainer_Plan_Container_Without_Name_Throws_Exception()
        {
            // Arrange
            Guid containerUId = Guid.NewGuid();

            ;
            PlanContainer container = new PlanContainer()
            {
                UId = containerUId
            };
            DynamoDbDal dal = new DynamoDbDal
            {
                ContainerTable = _containerTable
            };

            // Act
            Exception ex = Assert.Throws <Exception>(() => dal.UpsertPlanContainer(container));

            // Assert
            StringAssert.AreEqualIgnoringCase("Plan container name cannot be null or empty.", ex.Message);
        }
コード例 #5
0
        public void UpsertPlanContainer_Empty_Plan_Container_UId_Throws_Exception()
        {
            // Arrange
            Guid containerUId = Guid.Empty;

            ;
            PlanContainer container = new PlanContainer()
            {
                UId = containerUId
            };
            DynamoDbDal dal = new DynamoDbDal
            {
                ContainerTable = _containerTable
            };

            // Act
            Exception ex = Assert.Throws <Exception>(() => dal.UpsertPlanContainer(container));

            // Assert
            StringAssert.AreEqualIgnoringCase("Plan container unique id cannot be empty.", ex.Message);
        }
コード例 #6
0
        public void DeletePlanContainer_Existing_Container_Succeeds()
        {
            // Arrange
            Guid containerUId = Guid.NewGuid();

            ;
            PlanContainer container = new PlanContainer()
            {
                UId  = containerUId,
                Name = _containerPrefix + containerUId
            };
            DynamoDbDal dal = new DynamoDbDal
            {
                ContainerTable = _containerTable
            };

            // Act
            dal.UpsertPlanContainer(container);

            Assert.DoesNotThrow(() => dal.DeletePlanContainer(containerUId));
        }
コード例 #7
0
        public void UpsertPlanContainer_Non_Existent_Table_Throws_Exception()
        {
            // Arrange
            Guid containerUId = Guid.NewGuid();

            ;
            PlanContainer container = new PlanContainer()
            {
                UId  = containerUId,
                Name = _containerPrefix + containerUId
            };
            DynamoDbDal dal = new DynamoDbDal
            {
                ContainerTable = "XXXXXX"
            };

            // Act
            Exception ex = Assert.Throws <ResourceNotFoundException>(() => dal.UpsertPlanContainer(container));

            // Assert
            StringAssert.Contains("Requested resource not found: Table", ex.Message);
        }
コード例 #8
0
        public void UpsertPlanContainer_Null_Plan_Container_Table_Throws_Exception()
        {
            // Arrange
            Guid containerUId = Guid.NewGuid();

            ;
            PlanContainer container = new PlanContainer()
            {
                UId  = containerUId,
                Name = _containerPrefix + containerUId
            };
            DynamoDbDal dal = new DynamoDbDal
            {
                ContainerTable = ""
            };

            // Act
            Exception ex = Assert.Throws <Exception>(() => dal.UpsertPlanContainer(container));

            // Assert
            StringAssert.AreEqualIgnoringCase("Plan container table name must be specified.", ex.Message);
        }
コード例 #9
0
        public void UpsertPlanContainer_Valid_Details_Succeeds()
        {
            // Arrange
            Guid containerUId = Guid.NewGuid();

            ;
            PlanContainer container = new PlanContainer()
            {
                UId  = containerUId,
                Name = _containerPrefix + containerUId
            };
            DynamoDbDal dal = new DynamoDbDal
            {
                ContainerTable = _containerTable
            };

            // Act
            dal.UpsertPlanContainer(container);
            PlanContainer retContainer = dal.GetPlanContainerByUId(container.UId);

            // Assert
            Assert.AreEqual(container.UId, retContainer.UId);
            Assert.AreEqual(container.Name, retContainer.Name);
        }