Ejemplo n.º 1
0
        public void GetAll()
        {
            var options = new DbContextOptionsBuilder <FlixContext>()
                          .UseInMemoryDatabase(databaseName: "FlixUsersDatabase")
                          .Options;

            // Insert seed data into the database using one instance of the context
            using (var context = new FlixContext(options))
            {
                context.Watchlists.Add(new Watchlist {
                    Id = 1, MovieTitle = "Goodfellas", PlaylistId = 1
                });
                context.Watchlists.Add(new Watchlist {
                    Id = 2, MovieTitle = "God father", PlaylistId = 1
                });
                context.SaveChanges();
            }

            // Use a clean instance of the context to run the test
            using (var context = new FlixContext(options))
            {
                var watchlist = new WatchlistRepository(context);
                var addMovie  = watchlist.Getall();



                Assert.AreEqual(2, addMovie.Count);

                context.Dispose();
            }
        }
Ejemplo n.º 2
0
        public void GetPlaylistByID()
        {
            var options = new DbContextOptionsBuilder <FlixContext>()
                          .UseInMemoryDatabase(databaseName: "FlixUsersDatabase")
                          .Options;



            // Use a clean instance of the context to run the test
            using (var context = new FlixContext(options))
            {
                WatchlistRepository userRepo = new WatchlistRepository(context);
                var playlist = userRepo.GetMoviesByPlaylistId(1);

                Assert.AreEqual(2, playlist.Count);
                context.Dispose();
            }
        }
Ejemplo n.º 3
0
        public void AddPlaylist()
        {
            string title      = "MovieName";
            int    playListId = 2;


            var options = new DbContextOptionsBuilder <FlixContext>()
                          .UseInMemoryDatabase(databaseName: "FlixUsersDatabase")
                          .Options;

            // Use a clean instance of the context to run the test
            using (var context = new FlixContext(options))
            {
                WatchlistRepository playlist = new WatchlistRepository(context);
                var users     = playlist.AddMovie(title, playListId, "hello");
                var playlist1 = playlist.Getall();

                Assert.AreEqual(3, playlist1.Count);

                context.Dispose();
            }
        }
Ejemplo n.º 4
0
 public WatchlistManager(WatchlistRepository repository)
 {
     _repository = repository;
 }
Ejemplo n.º 5
0
        #pragma warning disable 1998
        public async override global::System.Threading.Tasks.Task ExecuteAsync()
        {
            BeginContext(12, 2, true);
            WriteLiteral("\r\n");
            EndContext();
            BeginContext(169, 4, true);
            WriteLiteral("\r\n\r\n");
            EndContext();
#line 8 "C:\Users\Ugesh\Desktop\dotcore2020\AuthenticationandAuthorization\AuthenticationandAuthorization\Views\Pet\Details.cshtml"
            var ifExists = WatchlistRepository.CheckIfAlreadyExists(UserManager.GetUserId(User), @Model.Id);

#line default
#line hidden
            BeginContext(274, 2, true);
            WriteLiteral("\r\n");
            EndContext();
#line 10 "C:\Users\Ugesh\Desktop\dotcore2020\AuthenticationandAuthorization\AuthenticationandAuthorization\Views\Pet\Details.cshtml"
            if (SignInManager.IsSignedIn(User) && Model.UserId != UserManager.GetUserId(User))
            {
#line default
#line hidden
                BeginContext(366, 31, true);
                WriteLiteral("    <div class=\"row\">\r\n        ");
                EndContext();
                BeginContext(397, 412, false);
                __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "ca279d452720c17fb890413ff9c295fae747d7a37788", async() => {
                    BeginContext(679, 55, true);
                    WriteLiteral("\r\n            <i class=\"fas fa-plus\"></i>\r\n            ");
                    EndContext();
                    BeginContext(736, 58, false);
#line 22 "C:\Users\Ugesh\Desktop\dotcore2020\AuthenticationandAuthorization\AuthenticationandAuthorization\Views\Pet\Details.cshtml"
                    Write(ifExists ? "Pet already exists in Watchlist" : "Watchlist");

#line default
#line hidden
                    EndContext();
                    BeginContext(795, 10, true);
                    WriteLiteral("\r\n        ");
                    EndContext();
                }
                                                                            );
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper>();
                __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper);
                BeginAddHtmlAttributeValues(__tagHelperExecutionContext, "class", 4, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
                AddHtmlAttributeValue("", 407, "btn", 407, 3, true);
                AddHtmlAttributeValue(" ", 410, "btn-primary", 411, 12, true);
                AddHtmlAttributeValue(" ", 422, "pull-right", 423, 11, true);
#line 14 "C:\Users\Ugesh\Desktop\dotcore2020\AuthenticationandAuthorization\AuthenticationandAuthorization\Views\Pet\Details.cshtml"
                AddHtmlAttributeValue(" ", 433, ifExists? "disabled" : "", 434, 28, false);

#line default
#line hidden
                EndAddHtmlAttributeValues(__tagHelperExecutionContext);
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Action = (string)__tagHelperAttribute_0.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0);
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Controller = (string)__tagHelperAttribute_1.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_1);
                if (__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues == null)
                {
                    throw new InvalidOperationException(InvalidTagHelperIndexerAssignment("asp-route-petId", "Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper", "RouteValues"));
                }
                BeginWriteTagHelperAttribute();
#line 17 "C:\Users\Ugesh\Desktop\dotcore2020\AuthenticationandAuthorization\AuthenticationandAuthorization\Views\Pet\Details.cshtml"
                WriteLiteral(Model.Id);

#line default
#line hidden
                __tagHelperStringValueBuffer = EndWriteTagHelperAttribute();
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues["petId"] = __tagHelperStringValueBuffer;
                __tagHelperExecutionContext.AddTagHelperAttribute("asp-route-petId", __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues["petId"], global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
                __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2);
                __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_3);
                __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_4);
                await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);

                if (!__tagHelperExecutionContext.Output.IsContentModified)
                {
                    await __tagHelperExecutionContext.SetOutputContentAsync();
                }
                Write(__tagHelperExecutionContext.Output);
                __tagHelperExecutionContext = __tagHelperScopeManager.End();
                EndContext();
                BeginContext(809, 14, true);
                WriteLiteral("\r\n    </div>\r\n");
                EndContext();
#line 25 "C:\Users\Ugesh\Desktop\dotcore2020\AuthenticationandAuthorization\AuthenticationandAuthorization\Views\Pet\Details.cshtml"
            }

#line default
#line hidden
            BeginContext(826, 9, true);
            WriteLiteral("\r\n<p>Id: ");
            EndContext();
            BeginContext(836, 8, false);
#line 27 "C:\Users\Ugesh\Desktop\dotcore2020\AuthenticationandAuthorization\AuthenticationandAuthorization\Views\Pet\Details.cshtml"
            Write(Model.Id);

#line default
#line hidden
            EndContext();
            BeginContext(844, 15, true);
            WriteLiteral("</p>\r\n<p>Name: ");
            EndContext();
            BeginContext(860, 10, false);
#line 28 "C:\Users\Ugesh\Desktop\dotcore2020\AuthenticationandAuthorization\AuthenticationandAuthorization\Views\Pet\Details.cshtml"
            Write(Model.Name);

#line default
#line hidden
            EndContext();
            BeginContext(870, 14, true);
            WriteLiteral("</p>\r\n<p>Age: ");
            EndContext();
            BeginContext(885, 9, false);
#line 29 "C:\Users\Ugesh\Desktop\dotcore2020\AuthenticationandAuthorization\AuthenticationandAuthorization\Views\Pet\Details.cshtml"
            Write(Model.Age);

#line default
#line hidden
            EndContext();
            BeginContext(894, 16, true);
            WriteLiteral("</p>\r\n<p>Color: ");
            EndContext();
            BeginContext(911, 11, false);
#line 30 "C:\Users\Ugesh\Desktop\dotcore2020\AuthenticationandAuthorization\AuthenticationandAuthorization\Views\Pet\Details.cshtml"
            Write(Model.Color);

#line default
#line hidden
            EndContext();
            BeginContext(922, 25, true);
            WriteLiteral("</p>\r\n<p>Selling Status: ");
            EndContext();
            BeginContext(949, 43, false);
#line 31 "C:\Users\Ugesh\Desktop\dotcore2020\AuthenticationandAuthorization\AuthenticationandAuthorization\Views\Pet\Details.cshtml"
            Write(Model.IsSelling ? "Selling" : "Not Selling");

#line default
#line hidden
            EndContext();
            BeginContext(993, 8, true);
            WriteLiteral("</p>\r\n\r\n");
            EndContext();
#line 35 "C:\Users\Ugesh\Desktop\dotcore2020\AuthenticationandAuthorization\AuthenticationandAuthorization\Views\Pet\Details.cshtml"
            if (Model.IsSelling)
            {
#line default
#line hidden
                BeginContext(1131, 8, true);
                WriteLiteral("        ");
                EndContext();
                BeginContext(1139, 127, false);
                __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "ca279d452720c17fb890413ff9c295fae747d7a314318", async() => {
                    BeginContext(1238, 24, true);
                    WriteLiteral("Remove from selling list");
                    EndContext();
                }
                                                                            );
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper>();
                __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper);
                __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_5);
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Action = (string)__tagHelperAttribute_6.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_6);
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Controller = (string)__tagHelperAttribute_7.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_7);
                if (__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues == null)
                {
                    throw new InvalidOperationException(InvalidTagHelperIndexerAssignment("asp-route-id", "Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper", "RouteValues"));
                }
                BeginWriteTagHelperAttribute();
#line 37 "C:\Users\Ugesh\Desktop\dotcore2020\AuthenticationandAuthorization\AuthenticationandAuthorization\Views\Pet\Details.cshtml"
                WriteLiteral(Model.Id);

#line default
#line hidden
                __tagHelperStringValueBuffer = EndWriteTagHelperAttribute();
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues["id"] = __tagHelperStringValueBuffer;
                __tagHelperExecutionContext.AddTagHelperAttribute("asp-route-id", __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues["id"], global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
                await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);

                if (!__tagHelperExecutionContext.Output.IsContentModified)
                {
                    await __tagHelperExecutionContext.SetOutputContentAsync();
                }
                Write(__tagHelperExecutionContext.Output);
                __tagHelperExecutionContext = __tagHelperScopeManager.End();
                EndContext();
                BeginContext(1266, 2, true);
                WriteLiteral("\r\n");
                EndContext();
#line 38 "C:\Users\Ugesh\Desktop\dotcore2020\AuthenticationandAuthorization\AuthenticationandAuthorization\Views\Pet\Details.cshtml"
            }
            else
            {
#line default
#line hidden
                BeginContext(1292, 8, true);
                WriteLiteral("        ");
                EndContext();
                BeginContext(1300, 123, false);
                __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "ca279d452720c17fb890413ff9c295fae747d7a317341", async() => {
                    BeginContext(1400, 19, true);
                    WriteLiteral("Add to selling list");
                    EndContext();
                }
                                                                            );
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper>();
                __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper);
                __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_8);
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Action = (string)__tagHelperAttribute_6.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_6);
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Controller = (string)__tagHelperAttribute_7.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_7);
                if (__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues == null)
                {
                    throw new InvalidOperationException(InvalidTagHelperIndexerAssignment("asp-route-id", "Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper", "RouteValues"));
                }
                BeginWriteTagHelperAttribute();
#line 41 "C:\Users\Ugesh\Desktop\dotcore2020\AuthenticationandAuthorization\AuthenticationandAuthorization\Views\Pet\Details.cshtml"
                WriteLiteral(Model.Id);

#line default
#line hidden
                __tagHelperStringValueBuffer = EndWriteTagHelperAttribute();
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues["id"] = __tagHelperStringValueBuffer;
                __tagHelperExecutionContext.AddTagHelperAttribute("asp-route-id", __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues["id"], global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
                await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);

                if (!__tagHelperExecutionContext.Output.IsContentModified)
                {
                    await __tagHelperExecutionContext.SetOutputContentAsync();
                }
                Write(__tagHelperExecutionContext.Output);
                __tagHelperExecutionContext = __tagHelperScopeManager.End();
                EndContext();
                BeginContext(1423, 2, true);
                WriteLiteral("\r\n");
                EndContext();
#line 42 "C:\Users\Ugesh\Desktop\dotcore2020\AuthenticationandAuthorization\AuthenticationandAuthorization\Views\Pet\Details.cshtml"
            }

#line default
#line hidden
            BeginContext(1437, 2, true);
            WriteLiteral("\r\n");
            EndContext();
        }