示例#1
0
        public async Task Get_Correct_Names_IngredientTypes()
        {
            var options        = Utils.GetOptions(nameof(Get_Correct_Names_IngredientTypes));
            var ingredientType = new IngredientType
            {
                Id   = Guid.Parse("619ac43c-075a-47be-befc-c68249054b85"),
                Name = "Rum"
            };

            var ingredientType2 = new IngredientType()
            {
                Id   = Guid.Parse("8ff6497e-800b-43ac-8f53-9492e38d60a1"),
                Name = "Tonic"
            };

            using (var arrangeContext = new CMContext(options))
            {
                arrangeContext.IngredientTypes.Add(ingredientType);
                arrangeContext.IngredientTypes.Add(ingredientType2);
                await arrangeContext.SaveChangesAsync();
            }

            using (var assertContext = new CMContext(options))
            {
                var sut    = new IngredientTypeService(assertContext);
                var result = await sut.GetAllIngredientTypes();

                Assert.AreEqual("Rum", result.ElementAt(0).Name);
                Assert.AreEqual("Tonic", result.ElementAt(1).Name);
            }
        }
示例#2
0
        public async Task Return_Correct_Updated_IngredientType()
        {
            var options = Utils.GetOptions(nameof(Return_Correct_Updated_IngredientType));

            var ingredientType = new IngredientType()
            {
                Id   = Guid.Parse("4a399308-dec0-4161-a679-18b4898c7e4b"),
                Name = "Liqeur"
            };

            using (var arrangeContext = new CMContext(options))
            {
                arrangeContext.IngredientTypes.Add(ingredientType);
                arrangeContext.SaveChanges();
            }

            var newName = "Liqeurr";

            using (var assertContext = new CMContext(options))
            {
                var sut    = new IngredientTypeService(assertContext);
                var result = await sut.UpdateIngredientType(ingredientType.Id, newName);

                Assert.AreEqual(ingredientType.Id, result.Id);
                Assert.AreEqual(newName, result.Name);
            }
        }
        public async Task Get_Correct_IngredientType()
        {
            var options        = Utils.GetOptions(nameof(Get_Correct_IngredientType));
            var ingredientType = new IngredientType
            {
                Id   = Guid.Parse("619ac43c-075a-47be-befc-c68249054b85"),
                Name = "Rum"
            };

            using (var arrangeContext = new CMContext(options))
            {
                arrangeContext.IngredientTypes.Add(ingredientType);
                await arrangeContext.SaveChangesAsync();
            }

            using (var assertContext = new CMContext(options))
            {
                var  sut        = new IngredientTypeService(assertContext);
                Guid resultGuid = new Guid("619ac43c-075a-47be-befc-c68249054b85");
                var  result     = await sut.GetIngredientType(resultGuid);

                Assert.AreEqual("Rum", result.Name);
                Assert.IsInstanceOfType(result, typeof(IngredientTypeDTO));
            }
        }
        public async Task Throw_Exception_When_IngredientType_IsNull()
        {
            var options = Utils.GetOptions(nameof(Throw_Exception_When_IngredientType_IsNull));

            using (var assertContext = new CMContext(options))
            {
                var sut = new IngredientTypeService(assertContext);
                await Assert.ThrowsExceptionAsync <ArgumentNullException>
                    (async() => await sut.CreateIngredientType(null));
            }
        }
示例#5
0
        public async Task Throw_When_DIngredientTypeNotFound()
        {
            var options = Utils.GetOptions(nameof(Throw_When_DIngredientTypeNotFound));

            using (var assertContext = new CMContext(options))
            {
                var  sut        = new IngredientTypeService(assertContext);
                Guid resultGuid = new Guid("4039e0f3-8d2d-43a5-a82b-477e42371cd6");

                await Assert.ThrowsExceptionAsync <ArgumentNullException>
                    (async() => await sut.DeleteIngredientType(resultGuid));
            }
        }
示例#6
0
        public async Task Throw_When_UpdIngredientTypeNotFound()
        {
            var options = Utils.GetOptions(nameof(Throw_When_UpdIngredientTypeNotFound));

            var newName = "Liqeurr";

            using (var assertContext = new CMContext(options))
            {
                var  sut    = new IngredientTypeService(assertContext);
                Guid ingrId = new Guid("4039e0f3-8d2d-43a5-a82b-477e42371cd6");

                await Assert.ThrowsExceptionAsync <ArgumentNullException>
                    (async() => await sut.UpdateIngredientType(ingrId, newName));
            }
        }
        public async Task Create_Correct_IngredientType()
        {
            var options = Utils.GetOptions(nameof(Create_Correct_IngredientType));

            using (var arrangeContext = new CMContext(options))
            {
                var sut         = new IngredientTypeService(arrangeContext);
                var ingrTypeDTO = await sut.CreateIngredientType(
                    new IngredientTypeDTO()
                {
                    Id   = Guid.Parse("619ac43c-075a-47be-befc-c68249054b85"),
                    Name = "Rum"
                });
            }

            using (var assertContext = new CMContext(options))
            {
                Assert.AreEqual("Rum", assertContext.IngredientTypes.First().Name);
            }
        }
示例#8
0
        public async Task ReturnTrue_When_IngredientTypeIsDeleted()
        {
            var options = Utils.GetOptions(nameof(ReturnTrue_When_IngredientTypeIsDeleted));

            var ingredientType = new IngredientType
            {
                Id   = Guid.Parse("619ac43c-075a-47be-befc-c68249054b85"),
                Name = "Rum"
            };

            using (var arrangeContext = new CMContext(options))
            {
                arrangeContext.IngredientTypes.Add(ingredientType);
                await arrangeContext.SaveChangesAsync();
            }
            using (var assertContext = new CMContext(options))
            {
                var  sut        = new IngredientTypeService(assertContext);
                Guid resultGuid = new Guid("619ac43c-075a-47be-befc-c68249054b85");
                var  result     = await sut.DeleteIngredientType(resultGuid);

                Assert.IsTrue(result);
            }
        }