示例#1
0
        public void Create_ThrowsDuplicateHopExpection()
        {
            try
            {
                using (var context = new DatabaseContext(options))
                {
                    IHopRepository service = new HopRepository(context, NullLogger <HopRepository> .Instance);
                    Warehouse      wh      = new Warehouse()
                    {
                        Code = "123456789", Description = "yo dawg", ProcessingDelayMins = 1
                    };
                    service.Create(wh);
                }

                using (var context = new DatabaseContext(options))
                {
                    IHopRepository service = new HopRepository(context, NullLogger <HopRepository> .Instance);
                    Warehouse      wh      = new Warehouse()
                    {
                        Code = "123456789", Description = "yo dawg", ProcessingDelayMins = 1
                    };
                    Assert.Throws <DuplicateHopExpection>(() => service.Create(wh));
                }
            }
            finally { }
        }
示例#2
0
        public void Create_IsSaved()
        {
            try
            {
                // Run the test against one instance of the context
                using (var context = new DatabaseContext(options))
                {
                    IHopRepository service = new HopRepository(context, NullLogger <HopRepository> .Instance);
                    Warehouse      wh      = new Warehouse()
                    {
                        Code = "123456789", Description = "yo dawg", ProcessingDelayMins = 1
                    };
                    service.Create(wh);
                }

                // Use a separate instance of the context to verify correct data was saved to database
                using (var context = new DatabaseContext(options))
                {
                    Assert.Equal(1, context.Hops.Count());
                    Assert.Equal("123456789", context.Hops.Single().Code);
                    Assert.Equal("yo dawg", context.Hops.Single().Description);
                }
            }
            finally { }
        }