Пример #1
0
        public async Task PostLanguage_CorrectLanguageWithCorrectValuesAndNonexistingIdSetted_CreatedAtActionResultWithSettedId()
        {
            // Arrange
            const int idToSet = 10;

            InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options, GetFakeList());

            Language languageToCreate = new Language()
            {
                Name = "NewDevelope",
                ID   = idToSet
            };

            // Act
            using (var context = new GameReviewsContext(options))
            {
                LanguagesController languagesController = new LanguagesController(context);
                var result = (await languagesController.PostLanguage(languageToCreate)).Result;

                // Assert
                Assert.True(context.Languages.Contains(languageToCreate));
                Assert.True(languageToCreate.ID == idToSet);
                Assert.IsType <CreatedAtActionResult>(result);
            }
        }
Пример #2
0
        public async Task PutLanguage_ExistingIdCorrectLanguageWithNameChanged_NoContentResult()
        {
            // Arrange
            const int languageId = 3;

            InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options, GetFakeList());

            Language languageToUpdate = GetFakeList().Where(d => d.ID == languageId).FirstOrDefault(),
            // Should use ICopyable interface here
                     expectedLanguage = GetFakeList().Where(d => d.ID == languageId).FirstOrDefault();


            // Act
            using (var context = new GameReviewsContext(options))
            {
                languageToUpdate.Name = "newName";
                expectedLanguage.Name = "newName";

                LanguagesController languagesController = new LanguagesController(context);
                var result = (await languagesController.PutLanguage(languageId, languageToUpdate));

                Language actualLanguage = await context.Languages.Where(d => d.ID == languageId).FirstOrDefaultAsync();

                // Assert
                Assert.True(AreEqual(expectedLanguage, actualLanguage));
                Assert.IsType <NoContentResult>(result);
            }
        }
Пример #3
0
        protected void gridMain_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            int recSkip = gridMain.CurrentPageIndex * gridMain.PageSize;
            int recTake = gridMain.PageSize;

            try {
                LanguagesController cont = new LanguagesController();
                gridMain.VirtualItemCount = cont.CountLanguages();
                gridMain.DataSource       = cont.GetLanguages(recSkip, recTake);
            }
            catch (Exception) { }
        }
Пример #4
0
        public async Task TestCase1()
        {
            var context = this.fixture.GetCurrentDataContext();
            LanguagesController control = new LanguagesController(context);

            // Read all
            var rsts    = control.Get();
            var rstscnt = await rsts.CountAsync();

            var cnt1 = DataSetupUtility.Languages.Count;

            Assert.Equal(cnt1, rstscnt);

            await context.DisposeAsync();
        }
Пример #5
0
        public async Task GetLanguage_NonexistentZeroId_NotFoundResult()
        {
            // Arrange
            const int languageId = 0;

            InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options, GetFakeList());

            // Act
            using (var context = new GameReviewsContext(options))
            {
                LanguagesController languagesController = new LanguagesController(context);
                var result = (await languagesController.GetLanguage(languageId)).Result;

                // Assert
                Assert.IsType <NotFoundResult>(result);
            }
        }
Пример #6
0
        public async Task DeleteLanguage_NegativeId_NotFoundResult()
        {
            // Arrange
            const int languageIdToDelete = -10;

            InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options, GetFakeList());
            Language expectedLanguage = GetFakeList().Where(d => d.ID == languageIdToDelete).FirstOrDefault();

            // Act
            using (var context = new GameReviewsContext(options))
            {
                LanguagesController languagesController = new LanguagesController(context);
                var actionResult = (await languagesController.DeleteLanguage(languageIdToDelete));
                var result       = actionResult.Result;

                // Assert
                Assert.IsType <NotFoundResult>(result);
            }
        }
Пример #7
0
        public async Task Setup()
        {
            // Arrange
            var datnekContext = await DatnekContextProvider.GetDatabaseContext();

            var languagesService = new LanguagesService(datnekContext);
            var user             = await GetUser(datnekContext);

            language = new Language()
            {
                slug       = "123",
                title      = "en",
                speak      = 2,
                read       = 3,
                understand = 2,
                userId     = user.id,
                user       = new User(),
                createdAt  = DateTime.Now,
                updatedAt  = DateTime.Now
            };
            languagesController = new LanguagesController(languagesService);
        }
Пример #8
0
        public async Task GetLanguage_ExistingId_TaskActionResultContainsLanguage()
        {
            // Arrange
            const int languageId = 3;

            Language expectedLanguage = GetFakeList().Where(d => d.ID == languageId).FirstOrDefault();

            InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options, GetFakeList());

            // Act
            using (var context = new GameReviewsContext(options))
            {
                LanguagesController languagesController = new LanguagesController(context);
                var          actionResult = (await languagesController.GetLanguage(languageId));
                Language     language     = actionResult.Value;
                ActionResult result       = actionResult.Result;

                // Assert
                Assert.True(AreEqual(expectedLanguage, language));
                Assert.IsNotType <NotFoundResult>(result);
            }
        }
Пример #9
0
        public async Task GetLanguages_Void_TaskActionResultContainsIEnumerableOfLanguage()
        {
            // Arrange
            List <Language> expectedData = GetFakeList();

            InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options, GetFakeList());

            // Act
            using (var context = new GameReviewsContext(options))
            {
                LanguagesController    languagesController = new LanguagesController(context);
                IEnumerable <Language> languages           = (await languagesController.GetLanguages()).Value;

                // Assert
                Assert.Equal(expectedData.Count, languages.Count());

                for (int i = 0; i < expectedData.Count; ++i)
                {
                    Assert.True(AreEqual(expectedData[i], languages.ElementAt(i)));
                }
            }
        }
Пример #10
0
 protected void gridMain_ItemDataBound(object sender, GridItemEventArgs e)
 {
     if (e.Item is GridFilteringItem)
     {
         GridFilteringItem filterItem = (GridFilteringItem)e.Item;
         RadDropDownList   cflist     = (RadDropDownList)filterItem.FindControl("ddlCountryFilter");
         RadDropDownList   ctflist    = (RadDropDownList)filterItem.FindControl("ddlCustomerTypeFilter");
         RadDropDownList   lflist     = (RadDropDownList)filterItem.FindControl("ddlLanguageFilter");
         RadDropDownList   uflist     = (RadDropDownList)filterItem.FindControl("ddlUserFilter");
         try {
             CountriesController ccont = new CountriesController();
             cflist.DataSource     = ccont.GetCountries();
             cflist.DataTextField  = "NameGR";
             cflist.DataValueField = "ID";
             cflist.DataBind();
             cflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0"));
             CustomerTypesController ctcont = new CustomerTypesController();
             ctflist.DataSource     = ctcont.GetCustomerTypes();
             ctflist.DataTextField  = "NameGR";
             ctflist.DataValueField = "ID";
             ctflist.DataBind();
             ctflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0"));
             LanguagesController lcont = new LanguagesController();
             lflist.DataSource     = lcont.GetLanguages();
             lflist.DataTextField  = "Name";
             lflist.DataValueField = "ID";
             lflist.DataBind();
             lflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0"));
             UsersController ucont = new UsersController();
             uflist.DataSource     = ucont.GetUsers();
             uflist.DataTextField  = "NameGR";
             uflist.DataValueField = "ID";
             uflist.DataBind();
             uflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0"));
         }
         catch (Exception) { }
     }
 }
Пример #11
0
        public async Task PostLanguage_CorrectLanguageWithCorrectValuesAndNegativeIdSetted_BadRequestResult()
        {
            // Arrange
            const int idToSet = -1;

            InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options, GetFakeList());

            Language languageToCreate = new Language()
            {
                Name = "NewDevelope",
                ID   = idToSet
            };

            // Act
            using (var context = new GameReviewsContext(options))
            {
                LanguagesController languagesController = new LanguagesController(context);
                var result = (await languagesController.PostLanguage(languageToCreate)).Result;

                // Assert
                Assert.IsType <BadRequestResult>(result);
            }
        }
Пример #12
0
        public async Task PutLanguage_ExistingIdCorrectLanguageWithIdChangedNegative_BadRequestResult()
        {
            // Arrange
            const int languageId = 3, idChanged = -1;

            InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options, GetFakeList());

            Language languageToUpdate = GetFakeList().Where(d => d.ID == languageId).FirstOrDefault();

            // Act
            using (var context = new GameReviewsContext(options))
            {
                languageToUpdate.ID = idChanged;

                LanguagesController languagesController = new LanguagesController(context);
                var result = (await languagesController.PutLanguage(languageId, languageToUpdate));

                Language actualLanguage = await context.Languages.Where(d => d.ID == languageId).FirstOrDefaultAsync();

                // Assert
                Assert.IsType <BadRequestResult>(result);
            }
        }
Пример #13
0
        public MegaClass(
            UserLicensesController a2,
            TimeEntrySuggestedRowsController a3,
            WorkHourSuggestedRowsController a4,
            KpiFormulasController a5,
            UserSettingsController a6,
            SecurityController a7,
            SoapApiKeysController a8,
            NotificationSettingsController a9,
            FlextimeAdjustmentsController a10,
            AuthorizedIpAddressesController a11,
            BankAccountsController a12,
            ApiClientsController a13,
            OrganizationSettingsController a14,
            LogosController a15,
            ProjectMemberCostExceptionsController a16,
            OrganizationDetailsController a17,
            AddonsController a18,
            TravelExpenseCountrySettingsController a19,
            ProductCountrySettingsController a20,
            CustomerCountrySettingsController a21,
            KpiComparisonController a22,
            TravelExpenseReceiptsController a23,
            TravelReimbursementStatusController a24,
            TravelReimbursementsController a25,
            ResourcingOverviewController a26,
            TermsOfServiceApprovalsController a27,
            FinancialsController a28,
            CalendarGroupMembersController a29,
            ActivityParticipantsController a30,
            ActivitiesController a31,
            PermissionProfilesController a32,
            CalendarGroupsController a33,
            ResourcesController a34,
            DemoDataController a35,
            LinksController a36,
            ReimbursedWorkHoursController a37,
            ReimbursedProjectTravelExpensesController a38,
            ReimbursedProjectFeesController a39,
            ProjectsOverviewController a40,
            ContactRolesController a41,
            CustomerMarketSegmentsController a42,
            ProjectTotalFeesController a43,
            BillingInformationUpdateController a44,
            KeywordsController a45,
            FlatRatesController a46,
            BusinessOverviewController a47,
            SpecialUserOptionsController a48,
            UninvoicedProjectsController a49,
            TeamProductivityController a50,
            ProjectBillingCustomersController a51,
            MarketSegmentsController a52,
            ProjectProductsController a53,
            ScheduleOverviewController a54,
            SharedDashboardAccessRightProfilesController a55,
            SharedDashboardsController a56,
            InvoicesOverviewController a57,
            ProposalBillingPlanController a58,
            SalesOverviewController a59,
            CustomersOverviewController a60,
            ProposalProjectPlanController a61,
            TimeEntryTypesController a62,
            CommunicationTypesController a63,
            ContactCommunicationsController a64,
            FlextimeController a65,
            ProjectForecastsController a66,
            ResourceAllocationsController a67,
            TemporaryProjectFeesController a68,
            InvoiceTemplateSettingsController a69,
            TemporaryProjectTravelExpensesController a70,
            TemporaryWorkHoursController a71,
            InvoiceTemplatesController a72,
            WorkdaysController a73,
            InvoiceSettingsController a74,
            OrganizationsController a75,
            ProjectTaskStatusesController a76,
            ActivityTypesController a77,
            AddressesController a78,
            DashboardPartsController a79,
            DashboardWithPartsController a80,
            DashboardsController a81,
            InvoiceRowsController a82,
            InvoicesController a83,
            HolidaysController a84,
            PermissionsController a85,
            QuickSearchController a86,
            ProposalTemplatesController a87,
            InvoiceTotalsController a88,
            ProposalTotalsController a89,
            ProposalWorkhoursController a90,
            ProposalSubtotalsController a91,
            ProposalFeesController a92,
            ReportsController a93,
            ProposalStatusesController a94,
            InvoiceStatusesController a95,
            ProposalsController a96,
            StatusHistoryController a97,
            PhaseStatusTypesController a98,
            CostCentersController a99,
            ProjectWorktypesController a100,
            PricelistVersionsController a101,
            OvertimePricesController a102,
            AllUsersController a103,
            TimeEntriesController a104,
            WorkTypesController a105,
            WorkHoursController a106,
            ProjectWorkHourPricesController a107,
            TravelPricesController a108,
            WorkHourPricesController a109,
            ProductPricesController a110,
            ProjectRecurringFeeRulesController a111,
            ProjectTravelExpensesController a112,
            TravelExpensesController a113,
            ProjectFeesController a114,
            SalesReceivableAccountsController a115,
            ValueAddedTaxesController a116,
            ProductsController a117,
            BusinessUnitsController a118,
            CollaborationNotesController a119,
            ContactsController a120,
            CurrencyBasesController a121,
            CurrenciesController a122,
            CountriesController a123,
            CustomersController a124,
            FileDataController a125,
            FilesController a126,
            FormattingCulturesController a127,
            IndustriesController a128,
            LanguagesController a129,
            LeadSourcesController a130,
            MenuController a131,
            PersonalSettingsController a132,
            PhaseMembersController a133,
            PhasesController a134,
            PricelistsController a135,
            OvertimesController a136,
            ProjectsController a137,
            ProjectStatusTypesController a138,
            SalesAccountsController a139,
            SalesNotesController a140,
            ProductCategoriesController a141,
            WorkContractsController a142,
            SalesStatusController a143,
            SalesStatusTypeController a144,
            TimeZonesController a145,
            UsersController a146,
            ScheduledWorkJobsController a147,
            PasswordChangeController a148,
            UserInactivationInformationController a149,
            EmailAddressChangeController a150,
            EmailController a151,
            PdfController a152,
            BearerAuthenticationController a153,
            ExternalAuthenticationController a154,
            HeartBeatController a155

            )
        {
            _a2   = _a2;
            _a3   = _a3;
            _a4   = _a4;
            _a5   = _a5;
            _a6   = _a6;
            _a7   = _a7;
            _a8   = _a8;
            _a9   = _a9;
            _a10  = _a10;
            _a11  = _a11;
            _a12  = _a12;
            _a13  = _a13;
            _a14  = _a14;
            _a15  = _a15;
            _a16  = _a16;
            _a17  = _a17;
            _a18  = _a18;
            _a19  = _a19;
            _a20  = _a20;
            _a21  = _a21;
            _a22  = _a22;
            _a23  = _a23;
            _a24  = _a24;
            _a25  = _a25;
            _a26  = _a26;
            _a27  = _a27;
            _a28  = _a28;
            _a29  = _a29;
            _a30  = _a30;
            _a31  = _a31;
            _a32  = _a32;
            _a33  = _a33;
            _a34  = _a34;
            _a35  = _a35;
            _a36  = _a36;
            _a37  = _a37;
            _a38  = _a38;
            _a39  = _a39;
            _a40  = _a40;
            _a41  = _a41;
            _a42  = _a42;
            _a43  = _a43;
            _a44  = _a44;
            _a45  = _a45;
            _a46  = _a46;
            _a47  = _a47;
            _a48  = _a48;
            _a49  = _a49;
            _a50  = _a50;
            _a51  = _a51;
            _a52  = _a52;
            _a53  = _a53;
            _a54  = _a54;
            _a55  = _a55;
            _a56  = _a56;
            _a57  = _a57;
            _a58  = _a58;
            _a59  = _a59;
            _a60  = _a60;
            _a61  = _a61;
            _a62  = _a62;
            _a63  = _a63;
            _a64  = _a64;
            _a65  = _a65;
            _a66  = _a66;
            _a67  = _a67;
            _a68  = _a68;
            _a69  = _a69;
            _a70  = _a70;
            _a71  = _a71;
            _a72  = _a72;
            _a73  = _a73;
            _a74  = _a74;
            _a75  = _a75;
            _a76  = _a76;
            _a77  = _a77;
            _a78  = _a78;
            _a79  = _a79;
            _a80  = _a80;
            _a81  = _a81;
            _a82  = _a82;
            _a83  = _a83;
            _a84  = _a84;
            _a85  = _a85;
            _a86  = _a86;
            _a87  = _a87;
            _a88  = _a88;
            _a89  = _a89;
            _a90  = _a90;
            _a91  = _a91;
            _a92  = _a92;
            _a93  = _a93;
            _a94  = _a94;
            _a95  = _a95;
            _a96  = _a96;
            _a97  = _a97;
            _a98  = _a98;
            _a99  = _a99;
            _a100 = _a100;
            _a101 = _a101;
            _a102 = _a102;
            _a103 = _a103;
            _a104 = _a104;
            _a105 = _a105;
            _a106 = _a106;
            _a107 = _a107;
            _a108 = _a108;
            _a109 = _a109;
            _a110 = _a110;
            _a111 = _a111;
            _a112 = _a112;
            _a113 = _a113;
            _a114 = _a114;
            _a115 = _a115;
            _a116 = _a116;
            _a117 = _a117;
            _a118 = _a118;
            _a119 = _a119;
            _a120 = _a120;
            _a121 = _a121;
            _a122 = _a122;
            _a123 = _a123;
            _a124 = _a124;
            _a125 = _a125;
            _a126 = _a126;
            _a127 = _a127;
            _a128 = _a128;
            _a129 = _a129;
            _a130 = _a130;
            _a131 = _a131;
            _a132 = _a132;
            _a133 = _a133;
            _a134 = _a134;
            _a135 = _a135;
            _a136 = _a136;
            _a137 = _a137;
            _a138 = _a138;
            _a139 = _a139;
            _a140 = _a140;
            _a141 = _a141;
            _a142 = _a142;
            _a143 = _a143;
            _a144 = _a144;
            _a145 = _a145;
            _a146 = _a146;
            _a147 = _a147;
            _a148 = _a148;
            _a149 = _a149;
            _a150 = _a150;
            _a151 = _a151;
            _a152 = _a152;
            _a153 = _a153;
            _a154 = _a154;
            _a155 = _a155;
        }
Пример #14
0
 protected void gridMain_ItemDataBound(object sender, GridItemEventArgs e)
 {
     if (e.Item is GridEditableItem && e.Item.IsInEditMode)
     {
         countryID = -1;
         Session.Remove("CountryID");
         customerTypeID = -1;
         Session.Remove("CustomerTypeID");
         languageID = -1;
         Session.Remove("LanguageID");
         userID = -1;
         Session.Remove("UserID");
         GridEditableItem item             = e.Item as GridEditableItem;
         RadDropDownList  ddlCountries     = item.FindControl("ddlCountries") as RadDropDownList;
         RadDropDownList  ddlCustomerTypes = item.FindControl("ddlCustomerTypes") as RadDropDownList;
         RadDropDownList  ddlLanguages     = item.FindControl("ddlLanguages") as RadDropDownList;
         RadDropDownList  ddlUsers         = item.FindControl("ddlUsers") as RadDropDownList;
         try {
             CustomerB           currCustomer  = e.Item.DataItem as CustomerB;
             CountriesController countriesCont = new CountriesController();
             ddlCountries.DataSource     = countriesCont.GetCountries();
             ddlCountries.DataTextField  = "NameGR";
             ddlCountries.DataValueField = "ID";
             ddlCountries.DataBind();
             if (currCustomer != null)
             {
                 ddlCountries.SelectedIndex = ddlCountries.FindItemByValue(currCustomer.CountryID.ToString()).Index;
                 Session["CountryID"]       = currCustomer.CountryID;
             }
             else
             {
                 ddlCountries.SelectedIndex = ddlCountries.FindItemByValue("1").Index;;
                 Session["CountryID"]       = ddlCountries.SelectedItem.Value;
             }
             CustomerTypesController customerTypesCont = new CustomerTypesController();
             ddlCustomerTypes.DataSource     = customerTypesCont.GetCustomerTypes();
             ddlCustomerTypes.DataTextField  = "NameGR";
             ddlCustomerTypes.DataValueField = "ID";
             ddlCustomerTypes.DataBind();
             if (currCustomer != null)
             {
                 ddlCustomerTypes.SelectedIndex = ddlCustomerTypes.FindItemByValue(currCustomer.CustomerTypeID.ToString()).Index;
                 Session["CustomerTypeID"]      = currCustomer.CustomerTypeID;
             }
             else
             {
                 ddlCustomerTypes.SelectedIndex = 0;
                 Session["CustomerTypeID"]      = ddlCustomerTypes.SelectedItem.Value;
             }
             LanguagesController languagesCont = new LanguagesController();
             ddlLanguages.DataSource     = languagesCont.GetLanguages();
             ddlLanguages.DataTextField  = "Name";
             ddlLanguages.DataValueField = "ID";
             ddlLanguages.DataBind();
             if (currCustomer != null)
             {
                 ddlLanguages.SelectedIndex = ddlLanguages.FindItemByValue(currCustomer.LanguageID.ToString()).Index;
                 Session["LanguageID"]      = currCustomer.LanguageID;
             }
             else
             {
                 ddlLanguages.SelectedIndex = ddlLanguages.FindItemByValue("1").Index;
                 Session["LanguageID"]      = ddlLanguages.SelectedItem.Value;
             }
             UsersController usersCont = new UsersController();
             ddlUsers.DataSource     = usersCont.GetUsers();
             ddlUsers.DataTextField  = "NameGR";
             ddlUsers.DataValueField = "ID";
             ddlUsers.DataBind();
             if (currCustomer != null)
             {
                 ddlUsers.SelectedIndex = ddlUsers.FindItemByValue(currCustomer.UserID.ToString()).Index;
                 Session["UserID"]      = currCustomer.UserID;
             }
             else
             {
                 ddlUsers.SelectedIndex = 0;
                 Session["UserID"]      = ddlUsers.SelectedItem.Value;
             }
         }
         catch (Exception) { }
     }
     if (e.Item is GridFilteringItem)
     {
         GridFilteringItem filterItem = (GridFilteringItem)e.Item;
         RadDropDownList   cflist     = (RadDropDownList)filterItem.FindControl("ddlCountryFilter");
         RadDropDownList   ctflist    = (RadDropDownList)filterItem.FindControl("ddlCustomerTypeFilter");
         RadDropDownList   lflist     = (RadDropDownList)filterItem.FindControl("ddlLanguageFilter");
         RadDropDownList   uflist     = (RadDropDownList)filterItem.FindControl("ddlUserFilter");
         try {
             CountriesController ccont = new CountriesController();
             cflist.DataSource     = ccont.GetCountries();
             cflist.DataTextField  = "NameGR";
             cflist.DataValueField = "ID";
             cflist.DataBind();
             cflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0"));
             CustomerTypesController ctcont = new CustomerTypesController();
             ctflist.DataSource     = ctcont.GetCustomerTypes();
             ctflist.DataTextField  = "NameGR";
             ctflist.DataValueField = "ID";
             ctflist.DataBind();
             ctflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0"));
             LanguagesController lcont = new LanguagesController();
             lflist.DataSource     = lcont.GetLanguages();
             lflist.DataTextField  = "Name";
             lflist.DataValueField = "ID";
             lflist.DataBind();
             lflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0"));
             UsersController ucont = new UsersController();
             uflist.DataSource     = ucont.GetUsers();
             uflist.DataTextField  = "NameGR";
             uflist.DataValueField = "ID";
             uflist.DataBind();
             uflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0"));
         }
         catch (Exception) { }
     }
 }