public void UpsertPlan_Existing_User_Succeeds()
        {
            // Arrange
            Guid     planUId = Guid.NewGuid();
            PlanItem plan    = new PlanItem()
            {
                UId        = planUId,
                Name       = _planPrefix + planUId,
                UniqueName = _planPrefix + planUId,
                IsActive   = false
            };
            DynamoDbDal dal = new DynamoDbDal
            {
                PlanTable = _planTable
            };

            // Act
            dal.UpsertPlan(plan);
            plan.IsActive = true;
            dal.UpsertPlan(plan);
            PlanItem retPlan = dal.GetPlanByUId(plan.UId);

            // Assert
            Assert.AreEqual(retPlan.UId, plan.UId);
            Assert.AreEqual(retPlan.Name, plan.Name);
            Assert.AreEqual(retPlan.IsActive, plan.IsActive);
        }
        public void GetPlanByUId_Null_Plan_Table_Throws_Exception()
        {
            // Arrange
            Guid planUId = Guid.NewGuid();

            DynamoDbDal dal = new DynamoDbDal
            {
                PlanTable = ""
            };
            // Act
            Exception ex = Assert.Throws <Exception>(() => dal.GetPlanByUId(planUId));

            // Assert
            StringAssert.AreEqualIgnoringCase(ex.Message, "Plan table name must be specified.");
        }
        public void GetPlanByUId_Non_Existent_Table_Throws_Exception()
        {
            // Arrange
            Guid planUId = Guid.NewGuid();

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

            // Act
            Exception ex = Assert.Throws <ResourceNotFoundException>(() => dal.GetPlanByUId(planUId));

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

            DynamoDbDal dal = new DynamoDbDal
            {
                PlanTable = _planTable
            };

            // Act
            Exception ex = Assert.Throws <Exception>(() => dal.GetPlanByUId(planUId));

            // Assert
            StringAssert.AreEqualIgnoringCase("Plan unique id cannot be empty.", ex.Message);
        }
        public void GetPlanByUId_Non_Existent_Plan_Throws_Exception()
        {
            // Arrange
            Guid planUId = Guid.NewGuid();


            DynamoDbDal dal = new DynamoDbDal
            {
                PlanTable = _planTable
            };

            // Act
            Exception ex = Assert.Throws <Exception>(() => dal.GetPlanByUId(planUId));

            // Assert
            StringAssert.AreEqualIgnoringCase("Plan cannot be found.", ex.Message);
        }
        public void UpsertPlan_Valid_Details_Succeeds()
        {
            // Arrange
            Guid     planUId = Guid.NewGuid();
            PlanItem plan    = new PlanItem()
            {
                UId        = planUId,
                Name       = _planPrefix + planUId,
                UniqueName = _planPrefix + planUId
            };
            DynamoDbDal dal = new DynamoDbDal
            {
                PlanTable = _planTable
            };

            // Act
            dal.UpsertPlan(plan);
            PlanItem retUser = dal.GetPlanByUId(plan.UId);

            // Assert
            Assert.AreEqual(plan.UId, retUser.UId);
            Assert.AreEqual(plan.Name, retUser.Name);
            Assert.AreEqual(plan.UniqueName, retUser.UniqueName);
        }