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);
        }
        public void GetPlanContainerByUId_Non_Existent_Plan_Container_Throws_Exception()
        {
            // Arrange
            Guid containerUId = Guid.NewGuid();

            DynamoDbDal dal = new DynamoDbDal
            {
                ContainerTable = _containerTable
            };

            // Act
            Exception ex = Assert.Throws <Exception>(() => dal.GetPlanContainerByUId(containerUId));

            // Assert
            StringAssert.Contains("Plan container cannot be found.", ex.Message);
        }
        public void GetPlanContainerByUId_Non_Existent_Table_Throws_Exception()
        {
            // Arrange
            Guid containerUId = Guid.NewGuid();

            DynamoDbDal dal = new DynamoDbDal
            {
                ContainerTable = "XXXXXX"
            };

            // Act
            Exception ex = Assert.Throws <ResourceNotFoundException>(() => dal.GetPlanContainerByUId(containerUId));

            // Assert
            StringAssert.Contains("Requested resource not found: Table", ex.Message);
        }
        public void GetPlanContainerByUId_Null_Plan_Container_Table_Throws_Exception()
        {
            // Arrange
            Guid containerUId = Guid.NewGuid();

            DynamoDbDal dal = new DynamoDbDal
            {
                ContainerTable = ""
            };

            // Act
            Exception ex = Assert.Throws <Exception>(() => dal.GetPlanContainerByUId(containerUId));

            // Assert
            StringAssert.AreEqualIgnoringCase("Plan container table name must be specified.", ex.Message);
        }
        public void GetPlanContainerByUId_Empty_Plan_Container_UId_Throws_Exception()
        {
            // Arrange
            Guid containerUId = Guid.Empty;

            DynamoDbDal dal = new DynamoDbDal
            {
                ContainerTable = _containerTable
            };

            // Act
            Exception ex = Assert.Throws <Exception>(() => dal.GetPlanContainerByUId(containerUId));

            // Assert
            StringAssert.AreEqualIgnoringCase("Plan container unique id cannot be empty.", ex.Message);
        }
        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);
        }