public void Test_That_ToBuilder_Returns_New_Instance()
        {
            var testClass = new Immutable <TestClass>();
            var builder   = testClass.ToBuilder();

            testClass.ShouldNotBe(builder.ToImmutable());
        }
        async Task <Immutable <CfnResponse> > CreateSeed(CfnRequest cfnRequest, Immutable <CfnResponse> cfnResponse, ILambdaContext context)
        {
            try
            {
                var seedData = cfnRequest.ResourceProperties.SeedData;
                if (seedData == null ||
                    seedData.Count() == 0 ||
                    (seedData.Count() == 1 && string.IsNullOrEmpty(seedData.First())))
                {
                    return(cfnResponse);
                }

                var request = seedData.Select(seed =>
                {
                    return(new SaveItemRequest
                    {
                        Id = "U1",
                        Name = "This is a custom data inserted using a custom resource",
                        Key = seed
                    });
                });

                var result = await _itemService.BatchWrite(request);

                if (result != null)
                {
                    LogHandler.LogMessage(context, "Db seeding successful");
                    return(cfnResponse.Modify(r => r.Status = "SUCCESS"));
                }
                else
                {
                    LogHandler.LogMessage(context, "Db seeding failed");
                    return(cfnResponse.ToBuilder()
                           .Modify(r => r.Status = "FAILED")
                           .Modify(r => r.Reason = $"Resource: {_tableName} not found")
                           .ToImmutable());
                }
            }
            catch (Exception ex)
            {
                LogHandler.LogMessage(context, ex.StackTrace);
                return(cfnResponse.ToBuilder()
                       .Modify(r => r.Status = "FAILED")
                       .Modify(r => r.Reason = ex.Message)
                       .ToImmutable());
            }
        }
        async Task <Immutable <CfnResponse> > DeleteTable(CfnRequest cfnRequest, Immutable <CfnResponse> cfnResponse, ILambdaContext context)
        {
            try
            {
                await _itemService.DeleteTable();

                await _userService.DeleteTable();

                LogHandler.LogMessage(context, $"Request {cfnRequest.RequestType} executed Successfully");
                return(cfnResponse.Modify(r => r.Status = "SUCCESS"));
            }
            catch (Exception ex)
            {
                LogHandler.LogMessage(context, $"Message: {ex.Message} /Trace: {ex.StackTrace}");
                return(cfnResponse.ToBuilder()
                       .Modify(r => r.Status = "FAILED")
                       .Modify(r => r.Reason = ex.Message)
                       .ToImmutable());
            }
        }
        public void Test_That_ToBuilder_Returns_New_Instance()
        {
            var testClass = new Immutable<TestClass>();
            var builder = testClass.ToBuilder();

            Assert.NotSame(testClass, builder);
        }