Ejemplo n.º 1
0
        public async Task ThorwWhenNoTheatreFound()
        {
            var options       = Utilities.GetOptions(nameof(ReturnCorrectTheatre));
            var secondId      = Guid.NewGuid();
            var testTheatre05 = new Theatre()
            {
                Id        = Guid.NewGuid(),
                Name      = "TestName",
                AboutInfo = "TestAboutInfo",
                Location  = "TestLocation",
                Phone     = "0896663554",
            };

            using (var assertContext = new TheatreContext(options))
            {
                await assertContext.Theatres.AddAsync(testTheatre05);

                await assertContext.SaveChangesAsync();
            }
            using (var assertContext = new TheatreContext(options))
            {
                var sut = new TheatreService(assertContext);
                await Assert.ThrowsExceptionAsync <Exception>(() => sut.GetTheatreAsync(secondId));
            }
        }
Ejemplo n.º 2
0
        public async Task ReturnCorrectTheatre()
        {
            var options       = Utilities.GetOptions(nameof(ReturnCorrectTheatre));
            var testIdGuid    = Guid.NewGuid();
            var testTheatre04 = new Theatre()
            {
                Id        = testIdGuid,
                Name      = "TestName",
                AboutInfo = "TestAboutInfo",
                Location  = "TestLocation",
                Phone     = "0896663554",
            };

            using (var assertContext = new TheatreContext(options))
            {
                await assertContext.AddAsync(testTheatre04);

                assertContext.SaveChanges();
                var sut    = new TheatreService(assertContext);
                var result = await sut.GetTheatreAsync(testIdGuid);

                Assert.IsInstanceOfType(result, typeof(Theatre));
                Assert.AreEqual(testTheatre04.Name, result.Name);
                Assert.AreEqual(testTheatre04.AboutInfo, result.AboutInfo);
                Assert.AreEqual(testTheatre04.Location, result.Location);
                Assert.AreEqual(testTheatre04.Phone, result.Phone);
            }
        }