public void Constructor() { DatabaseActions databaseActions = new DatabaseActions(connectionDetails.ToString()); string expected = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Test2;Integrated Security=True"; Assert.AreEqual(expected, databaseActions.ConnectionString); }
public void IsLocalDbFalse() { connectionDetails.DataSource = "server1"; DatabaseActions databaseActions = new DatabaseActions(connectionDetails.ToString()); Assert.IsFalse(databaseActions.IsLocalDB); }
public void AddCatalogTest() { DataChamber data = new DataChamber(); DefaultDataGeneration filler = new DefaultDataGeneration(); DatabaseActions test = new DatabaseActions(data, filler); Catalog catalog = new Catalog("Andrzej", "Sapkowski", 2000, "The Witcher", 8); test.AddCatalog(catalog); Assert.AreEqual(test.ReadCatalog(8), catalog); }
public void UpdateCatalogTest() { DefaultDataGeneration filler = new DefaultDataGeneration(); DataChamber data = new DataChamber(); DatabaseActions test = new DatabaseActions(data, filler); Catalog newCatalog = new Catalog("Lokok", "Test", 1908, "Testowy", 9); test.UpdateCatalog(3, newCatalog); Assert.AreEqual(newCatalog, test.ReadCatalog(3)); }
public void UpdateUsersTest() { DefaultDataGeneration filler = new DefaultDataGeneration(); DataChamber data = new DataChamber(); DatabaseActions test = new DatabaseActions(data, filler); Users newUser = new Users(1, "Test", "Testowy", 1908); test.UpdateUser(1, newUser); Assert.AreEqual(newUser, test.ReadUser(1)); }
public void RandomFillTest() { RandomDataGeneration ranDataGeneration = new RandomDataGeneration(); DataChamber chamber = new DataChamber(); DatabaseActions databaseActions = new DatabaseActions(chamber, ranDataGeneration); Assert.AreEqual(10, databaseActions.ReadAllCatalogs().Count); Assert.AreEqual(10, databaseActions.ReadAllUsers().Count); Assert.AreEqual(10, databaseActions.ReadAllProcessStates().Count); Assert.AreEqual(10, databaseActions.ReadAllEvents().Count); }
public void AddUserTest() { DataChamber data = new DataChamber(); DefaultDataGeneration filler = new DefaultDataGeneration(); DatabaseActions test = new DatabaseActions(data, filler); Users user = new Users(5, "Wojciech", "Mincikiewicz", 1996); test.AddUser(user); Assert.AreEqual(test.ReadUser(5), user); }
public void UpdateProcessStateTest() { DefaultDataGeneration filler = new DefaultDataGeneration(); DataChamber data = new DataChamber(); DatabaseActions test = new DatabaseActions(data, filler); Catalog newCatalog = new Catalog("Lokok", "Test", 1908, "Testowy", 9); ProcessState newProcessState = new ProcessState(newCatalog, "Testowy", 1789, "Bad"); test.UpdateProcessState(4, newProcessState); Assert.AreEqual(newProcessState, test.ReadProcessState(4)); }
public void AddProcessStateTest() { DataChamber data = new DataChamber(); DefaultDataGeneration filler = new DefaultDataGeneration(); DatabaseActions test = new DatabaseActions(data, filler); Catalog catalog = new Catalog("Andrzej", "Sapkowski", 2000, "The Witcher", 8); ProcessState processState = new ProcessState(catalog, "Znak", 1990, "Good"); test.AddProcessState(processState); Assert.AreEqual(test.ReadProcessState(5), processState); }
public static async Task LevelsClient_MessageDeleted(DiscordClient sender, MessageDeleteEventArgs messageDeleteEventArgs) { if (!LevelOptions.RemoveExpOnMessageDelete) { return; } if (messageDeleteEventArgs.Message.Author.IsBot) { return; } await DatabaseActions.RevokeExp(messageDeleteEventArgs.Message.Author.Id.ToString()); }
public void DeleteCatalogTest() { DefaultDataGeneration filler = new DefaultDataGeneration(); DataChamber data = new DataChamber(); DatabaseActions test = new DatabaseActions(data, filler); Catalog newCatalog = new Catalog("Lokok", "Test", 1908, "Testowy", 5); test.AddCatalog(newCatalog); Assert.AreEqual(test.ReadCatalog(5), newCatalog); test.DeleteCatalog(5); Assert.IsFalse(test.ReadAllCatalogs().ContainsValue(newCatalog)); }
public void DeleteUsersTest() { DefaultDataGeneration filler = new DefaultDataGeneration(); DataChamber data = new DataChamber(); DatabaseActions test = new DatabaseActions(data, filler); Users newUser = new Users(1, "Test", "Testowy", 1908); test.AddUser(newUser); Assert.AreEqual(test.ReadUser(5), newUser); test.DeleteUser(5); Assert.IsFalse(test.ReadAllUsers().Contains(newUser)); }
public void ReadAllEventsTest() { DefaultDataGeneration filler = new DefaultDataGeneration(); List <Users> usersList = new List <Users>(); Dictionary <int, Catalog> catalogDictionary = new Dictionary <int, Catalog>(); List <Event> eventsList = new List <Event>(); List <ProcessState> processStateList = new List <ProcessState>(); DataChamber data = new DataChamber(usersList, catalogDictionary, eventsList, processStateList); DatabaseActions test = new DatabaseActions(data, filler); Assert.AreEqual(eventsList, test.ReadAllEvents()); }
public void ReadCatalogTest() { DataChamber data = new DataChamber(); DefaultDataGeneration filler = new DefaultDataGeneration(); DatabaseActions test = new DatabaseActions(data, filler); Catalog readCatalog = test.ReadCatalog(3); Assert.AreEqual(readCatalog.getAuthorsName(), "Scott"); Assert.AreEqual(readCatalog.getAuthorsSurname(), "Fitzgerald"); Assert.AreEqual(readCatalog.getTitle(), "The Great Gatsby"); Assert.AreEqual(readCatalog.getKey(), 3); Assert.AreEqual(readCatalog.getPublicationDate(), 1925); }
public CommandRouter MakeRouter() { CommandRouter commandRouter = new CommandRouter(); commandRouter.AddCommand("database", "create", new Command(DatabaseActions.CreateDatabaseAsync)); commandRouter.AddCommand("database", "view", new Command(_ => DatabaseActions.ViewDatabasesAsync())); commandRouter.AddCommand("database", "delete", new Command(DatabaseActions.DeleteDatabaseAsync)); commandRouter.AddCommand("container", "create", new Command(ContainerActions.CreateContainerAsync)); commandRouter.AddCommand("container", "view", new Command(ContainerActions.ViewContainersAsync)); commandRouter.AddCommand("container", "delete", new Command(ContainerActions.DeleteContainerAsync)); return(commandRouter); }
public void DeleteProcessStateTest() { DefaultDataGeneration filler = new DefaultDataGeneration(); DataChamber data = new DataChamber(); DatabaseActions test = new DatabaseActions(data, filler); Catalog newCatalog = new Catalog("Lokok", "Test", 1908, "Testowy", 9); ProcessState newProcessState = new ProcessState(newCatalog, "Testowy", 1789, "Bad"); test.AddProcessState(newProcessState); Assert.AreEqual(test.ReadProcessState(5), newProcessState); test.DeleteProcessState(5); Assert.IsFalse(test.ReadAllProcessStates().Contains(newProcessState)); }
public void ReadUserTest() { DataChamber data = new DataChamber(); DefaultDataGeneration filler = new DefaultDataGeneration(); DatabaseActions test = new DatabaseActions(data, filler); Users readUser = test.ReadUser(3); //Users user4 = new Users(3, "Andrzej", "Paluch", 1996); Assert.AreEqual(readUser.getName(), "Andrzej"); Assert.AreEqual(readUser.getSurname(), "Paluch"); Assert.AreEqual(readUser.getId(), 3); Assert.AreEqual(readUser.getDate(), 1996); //Assert.AreEqual(readUser, user4); }
public void ReadProcessStateTest() { DataChamber data = new DataChamber(); DefaultDataGeneration filler = new DefaultDataGeneration(); DatabaseActions test = new DatabaseActions(data, filler); ProcessState readProcessState = test.ReadProcessState(3); Assert.AreEqual(readProcessState.getCatalog().getAuthorsName(), "Harper"); Assert.AreEqual(readProcessState.getCatalog().getAuthorsSurname(), "Lee"); Assert.AreEqual(readProcessState.getCatalog().getTitle(), "To Kill a Mockingbird"); Assert.AreEqual(readProcessState.getCatalog().getPublicationDate(), 1960); Assert.AreEqual(readProcessState.getCatalog().getKey(), 1); Assert.AreEqual(readProcessState.getPublisher(), "Znak"); Assert.AreEqual(readProcessState.getBookState(), "Bad"); Assert.AreEqual(readProcessState.getReleaseDate(), 2001); }
public void AddEventTest() { DataChamber data = new DataChamber(); DefaultDataGeneration filler = new DefaultDataGeneration(); DatabaseActions test = new DatabaseActions(data, filler); Users user = new Users(1, "Wojciech", "Mincikiewicz", 1996); Catalog catalog = new Catalog("Andrzej", "Sapkowski", 2000, "The Witcher", 8); ProcessState processState = new ProcessState(catalog, "Znak", 1990, "Good"); DateTime checkOutDate = new DateTime(2010, 10, 12); DateTime checkInDate = new DateTime(1993, 4, 6); Event evn = new Event(processState, user, checkOutDate, checkInDate); test.AddEvent(evn); Assert.AreEqual(test.ReadEvent(5), evn); }
public void UpdateEventTest() { DefaultDataGeneration filler = new DefaultDataGeneration(); DataChamber data = new DataChamber(); DatabaseActions test = new DatabaseActions(data, filler); Users newUser = new Users(1, "Test", "Testowy", 1908); Catalog newCatalog = new Catalog("Lokok", "Test", 1908, "Testowy", 9); ProcessState newProcessState = new ProcessState(newCatalog, "Testowy", 1789, "Bad"); DateTime checkOutDate = new DateTime(2000, 10, 12); DateTime checkInDate = new DateTime(1990, 4, 6); Event newEvent = new Event(newProcessState, newUser, checkOutDate, checkInDate); test.UpdateEvent(2, newEvent); Assert.AreEqual(newEvent, test.ReadEvent(2)); }
private void MainViewCommands(object obj) { switch (obj.ToString()) { case "fetchData": ListViewContent = DatabaseActions.GetTableContent(Settings.DbLocation, SelectedTable); break; case "changeDatasource": OpenFileDialog fDialog = new OpenFileDialog(); if (fDialog.ShowDialog() == true) { DatabaseLocation = fDialog.FileName; Settings.DbLocation = fDialog.FileName; Tables = DatabaseActions.GetTableNames(Settings.DbLocation); } break; } }
private IEnumerable <PropertyInfo> _getProperties(T item, DatabaseActions action) { var _props = item.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); var properties = new Stack <PropertyInfo>(_props.Length); foreach (var property in _props) { var attributes = property.GetCustomAttributes(true); switch (action) { case DatabaseActions.Insert: if (!attributes.Any(x => x is IgnoreAttribute attribute && attribute.WhenInsert)) { properties.Push(property); } break; case DatabaseActions.Update: if (!attributes.Any(x => x is IgnoreAttribute attribute && attribute.WhenUpdate)) { properties.Push(property); } break; case DatabaseActions.Delete: properties.Push(property); break; case DatabaseActions.Select: default: properties.Push(property); break; } } return(properties); }
public async Task GetUserVoiceLevel(CommandContext ctx) { var user = DatabaseActions.GetUserExp(ctx.User.Id, true).Result; if (user == null) { return; } var args = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("Level", user.Rows[0]["level"].ToString()), new KeyValuePair <string, string>("Exp", user.Rows[0]["voice_exp"].ToString()) }; var avatar = ctx.Member.AvatarUrl; if (user.Rows[0]["badgeImageUrl"] != DBNull.Value) { avatar = user.Rows[0]["badgeImageUrl"].ToString(); } DiscordEmbed embed = LevelTasks.BuildEmbedTask("Voice Exp!", "Levels!", ctx.Guild.IconUrl, args, avatar); await ctx.RespondAsync(embed : embed); }
public void ReadEventTest() { DataChamber data = new DataChamber(); DefaultDataGeneration filler = new DefaultDataGeneration(); DatabaseActions test = new DatabaseActions(data, filler); DateTime checkOutDate = new DateTime(2018, 4, 6); DateTime checkInDate = new DateTime(2018, 12, 12); Event readEvent = test.ReadEvent(3); Assert.AreEqual(readEvent.getProcessState().getCatalog().getAuthorsName(), "George"); Assert.AreEqual(readEvent.getProcessState().getCatalog().getAuthorsSurname(), "Orwell"); Assert.AreEqual(readEvent.getProcessState().getCatalog().getTitle(), "1984"); Assert.AreEqual(readEvent.getProcessState().getCatalog().getPublicationDate(), 1949); Assert.AreEqual(readEvent.getProcessState().getCatalog().getKey(), 2); Assert.AreEqual(readEvent.getProcessState().getPublisher(), "Amber"); Assert.AreEqual(readEvent.getProcessState().getBookState(), "Average"); Assert.AreEqual(readEvent.getProcessState().getReleaseDate(), 1986); Assert.AreEqual(readEvent.getUsers().getName(), "Kasia"); Assert.AreEqual(readEvent.getUsers().getSurname(), "Kowalska"); Assert.AreEqual(readEvent.getUsers().getDate(), 1993); Assert.AreEqual(readEvent.getUsers().getId(), 1); Assert.AreEqual(readEvent.getCheckOutDate(), checkOutDate); Assert.AreEqual(readEvent.getCheckInDate(), checkInDate); }
public MainViewViewModel() { DefaultCommand = new Commands.DefaultCommand(MainViewCommands); DatabaseLocation = Settings.DbLocation; Tables = DatabaseActions.GetTableNames(Settings.DbLocation); }
public void GivenThereIsATestDatabase() { database = new DatabaseActions(@"server=(localdb)\MSSQLLocalDB;database=Test2;integrated security=True"); database.CreateOrReplace(); ScenarioContext.Current["Database"] = database; }
public void IsLocalDb() { DatabaseActions databaseActions = new DatabaseActions(connectionDetails.ToString()); Assert.IsTrue(databaseActions.IsLocalDB); }
public void SetUp() { _contextMock = new Mock <ILambdaContext>(); _databaseActions = new DatabaseActions(); _databaseActions.SetupDatabase(_contextMock.Object); }
public AdultsController(AdultContext context, DatabaseActions databaseActions) { _context = context; dbAction = databaseActions; }
public void InsertNullTableData() { DatabaseActions database = new DatabaseActions(connectionString); tableDefinition.Insert(database, null); }
/// <summary> /// Loads a form to the panel /// </summary> /// <param name="tag">The tag of the button - Here is stored what type of form is supposed to be opened</param> private void LoadForm(string tag) { var yEnd = new YearEnd(); if (yEnd.InventoryRequired(false)) { switch (VisibilitySetting.HandleUnits) { case 1: yEnd.GenerateAutomaticInventory(); break; case 2: yEnd.GenerateAutomaticInventoryByUnit(); break; case 3: yEnd.GenerateAutomaticInventoryByUnit(); break; } } Form frm; switch (tag) { case "Receives": frm = new ReceivingForm(); AddTab("Receiving Form", frm); break; case "Issues": frm = new IssueForm(); AddTab("Issue Form", frm); break; case "AMCs": frm = new AMCView(); AddTab("AMC Report", frm); break; case "menuItemPriceOnlyReport": frm = new ItemPriceOnlyReport(); AddTab("Item Price Only", frm); break; case "Facility Settings": frm = new Hospital(); AddTab("Facility Settings", frm); break; case "Drug List": frm = new ManageItems(); AddTab("Manage Drug List", frm); break; case "Supplies List": //frm = new ManageItems(); frm = new ManageSupplies(); AddTab("Manage Supplies List", frm); break; case "Item Consolidator": //frm = new ManageItems(); frm = new ItemConsolidator(); AddTab("Update Items List From The Directory Service", frm); break; case "Customize Druglist": frm = new CustomDrugList(); AddTab("Customize Drug List", frm); break; case "System Settings": frm = new SystemSetting(); AddTab("System Settings", frm); break; case "Facility Details": frm = new HospitalSettings(); AddTab("Facility Details", frm); break; case "User Accounts": frm = new UserAccounts(); AddTab("Manage Users", frm); break; case "Pipeline": frm = new Pipeline(); AddTab("Pipeline", frm); break; case "Change Password": frm = new ChangePassword(UserId); AddTab("Change Password", frm); break; case "Transfer Log": frm = new LogTransfer(); AddTab("Transfer Log", frm); break; case "VRF Form": frm = new vrfmainForm(); AddTab("Vaccine Requistion and Report Form", frm); break; case "Losses/Adjustment": frm = new LossesAdjustment(); AddTab("Losses and Adjustment", frm); break; case "Receive Log": frm = new LogReceive(); AddTab("Receive Transaction Log", frm); break; case "Issue Log": frm = new LogIssues(); AddTab("Issue Transaction Log", frm); break; case "Adjustment Log": frm = new LogAdjustment(); AddTab("Loss / Adjustment Transaction Log", frm); break; case "Inventory Log": frm = new LogInventory(); AddTab("Inventory Log", frm); break; case "Stock Status": frm = new ItemReport(); AddTab("Stock Status", frm); break; case "Over Stocked": frm = new OtherItemReport("Over Stocked"); AddTab("Over Stock Items", frm); break; case "Transfers": frm = new TransferForm(); AddTab("Transfer Form", frm); break; case "Stock Out": frm = new OtherItemReport("Stock Out"); AddTab("Stocked Out Items", frm); break; case "ConsumptionTrend": frm = new ConsumptionTrendReport(); AddTab("Consumption Trend", frm); break; case "Issues By Receiving Unit": frm = new IssuesByDep(); AddTab("Issues By Receiving Unit", frm); break; case "Expired Products": frm = new ExpiredProducts(); AddTab("Expired Products", frm); break; case "Near Expiry": frm = new NearlyExpired(); AddTab("Near Expiry Products", frm); break; case "SOH Trend": frm = new SOHTrend(); AddTab("SOH Trend", frm); break; case "Receive Trend": frm = new ReceiveTrend(); AddTab("Receive Trend", frm); break; case "Balance": frm = new BalanceReport(); AddTab("Balance", frm); break; case "Summary Report": frm = new GeneralReport(); AddTab("Summary Report", frm); break; case "Cost Summary": frm = new GeneralCostChart(); AddTab("Cost Summary", frm); break; case "Wastage Rate": frm = new WastageRate(); AddTab("Wastage Rate", frm); break; case "Summary Chart": frm = new GeneralChart(); AddTab("General Chart", frm); break; case "Activity Log Reports": frm = new ActivityLogReports(); AddTab("Activity Log", frm); break; case "ECLS": frm = new ECLS(); AddTab("CS Stock Status", frm); break; case "Year End Process": frm = new YearEndProcess(); AddTab("Inventory", frm); break; case "Default Year End Process": frm = new YearEndProcess(true); AddTab("Inventory", frm); break; case "Stock Expiry Status": frm = new GeneralExpiryChart(); AddTab("Stock Status", frm); break; case "DataBase": frm = new DatabaseActions(); AddTab("Database Actions", frm); break; case "PDA": frm = new ItemReport(); AddTab("Stock Status", frm); break; case "Consumables List": frm = new ManageSupplies(); AddTab("Supplies List", frm); break; case "RRF Form": frm = new RRFForm(); AddTab("Report and Requisition Form", frm); break; case "LossReport": frm = new ExpiredProductsReport(); AddTab("Loss / Adjustment Reporting View", frm); break; case "CostReport": frm = new CostReport(); AddTab("Cost Report", frm); break; case "ConsumptionByUnit": frm = new ConsumptionByUnits(); AddTab("Consumption By Dispensary Unit", frm); break; case "About": Program.ShowHCMISVersionInfoMessageBox(); break; } }