private void ShowList() { SetMessage("", false); DataContextContainer.ItemsSource = null; switch (currentlySelectedList) { case AvailableLists.BookList: { DataContextTitle.Content = "Books"; DataContextContainer.ItemsSource = LibService.GetAllBooks(); break; } case AvailableLists.ClientList: { DataContextTitle.Content = "Clients"; DataContextContainer.ItemsSource = LibService.GetAllClients(); break; } case AvailableLists.RentList: { DataContextTitle.Content = "Rents"; DataContextContainer.ItemsSource = LibService.GetAllRents(); break; } default: { DataContextTitle.Content = ""; break; } } }
public void BookIdIsNull() { // Arrange var mock = new Mock <IUnitOfWork>(); LibService service = new LibService(mock.Object); // Act and assert Assert.ThrowsException <System.ArgumentNullException>(() => service.GiveBook(5, null)); }
public void ReaderIdIsNull() { // Arrange var mock = new Mock <IUnitOfWork>(); LibService service = new LibService(mock.Object); // Act and assert Assert.ThrowsException <System.ArgumentNullException>(() => service.ReturnBook(null, 5)); }
public void ReaderIsNotFound() { // Arrange var mock = new Mock <IUnitOfWork>(); mock.Setup(a => a.Readers.Get(1)).Returns((Reader)null); LibService service = new LibService(mock.Object); // Act and assert Assert.ThrowsException <System.InvalidOperationException>(() => service.GetReader(1)); }
public void LibService_CreateAnObject() { // arrange string expected = "LibService"; UnitOfWork unit = new UnitOfWork(); // act LibService libService = new LibService(unit); //assert Assert.IsNotNull(libService); Assert.AreEqual(expected, libService.GetType().Name); }
public void AddAnAuthorAndBook_ViewResultNotNull() { //Arrange var mock2 = new Mock <IConfiguration>(); IUnitOfWork unitOfWorkTest = new UnitOfWork(); ILibService libServiceTest = new LibService(unitOfWorkTest); BookController controller = new BookController(libServiceTest, mock2.Object); //Act ViewResult result = controller.AddAnAuthorAndBook() as ViewResult; //Assert Assert.IsNotNull(result); }
private void RemoveButton_Click(object sender, RoutedEventArgs e) { object selection = DataContextContainer.SelectedItem; if (selection != null) { switch (currentlySelectedList) { case AvailableLists.BookList: { Book book = (Book)selection; if (LibService.CanRemoveBook(book.Id)) { LibService.RemoveBook(book); SetMessage("Book " + book.Title + " was successfully removed.", false); Refresh(); } else { SetMessage("Book " + book.Title + " is still rented!", true); } break; } case AvailableLists.ClientList: { Client client = (Client)selection; if (LibService.CanRemoveClient(client.Id)) { LibService.RemoveClient(client); SetMessage("Client " + client.GetClientName() + " was successfully removed.", false); Refresh(); } else { SetMessage("Client " + client.GetClientName() + " still owns books!", true); } break; } default: break; } } }
private void ReturnBookButton_Click(object sender, RoutedEventArgs e) { object selection = DataContextContainer.SelectedItem; if (selection != null) { Book book = (Book)selection; if (!book.IsTaken) { SetMessage("Book " + book.Title + " is not currently rented!", true); } else { LibService.RemoveRent(book); SetMessage("Book " + book.Title + " has been returned.", false); } Refresh(); } }
private void RemoveAllButton_Click(object sender, RoutedEventArgs e) { switch (currentlySelectedList) { case AvailableLists.BookList: { LibService.RemoveAllBooks(); Refresh(); break; } case AvailableLists.ClientList: { LibService.RemoveAllClients(); Refresh(); break; } default: break; } }
public MainWindow() { ServiceData.Init(@"Data/Service.xlsx"); Release.Init(Assembly.GetExecutingAssembly().GetName().Version); _windowSplash = new WindowSplash(); _windowSplash.Show(); Opc.UaFx.Client.Licenser.LicenseKey = "AALOERR5OO7EKFNQCABINGCH6TYOVHPLFC2QCUYAV3IYL7FGRNBJ4TYJX2GM6HKSCKZLBJWGHUWWXQ5HKWI7OFVYYMERDPQDC7ZW7ZTLPTM" + "LWLMY3RMLD2UQ6OXKUKC2YBBPBRGK6SBRI4DBXF4NGVKZUATMW3VI7EALG5FQNCETII7JG7OTOCL2EPO55TO5D4GPJROX5FHSUSALQX56E6" + "NCBRCDX35VJBWLQDD4QANXIWUKO7D3Q7SWDDL55ZZCSN7NLHKB3W5O524VIXFPLVJIYKM5U4OPRXPQ2IM5HNR5GRY4ZODEIIKTRJS2N2MBD" + "LYUUDDNUH5Y7X2MERUMPKZZHP3WWLGR2XUCXTZTA6MWSB6KXNJ3DMIA6ZU54UQVFC3FGTOU5YP2CHBVZOFZDZTDD2OX3XD5ZMPQTS4DU7C5" + "44BBNUXMNCNQ52DQSVBF3YYGV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5H8f" + "WkYXqiSRovW8fvjzPHMKsHri+ywu+vv1sGfAwA0zzPsF2OEmeNC34NoNvq0aHta9JYfhfq9bkKZym8x02csbJJuI2R" + "c3V1rG5B/jATAQfCMOVMRttnnmQ6VnSEiSRStLhvBtVE0bC1kq4Z4RNpUVrGVcBn6w41aSyD8uOc78dBIu7a3ykZ45" + "1A/Q3ww3T1GtnmfAkGLK2b/srd675k7fpZrVlyiLH7BfEyo+hrBj51dYG0IaJqzseeuSh7GFjJZCihujJNgugyR4Id" + "N4KjrZg2sAuO4JeNlvzZvyQ7wNzu92lFHGoZGLnnKIAUQUk8FECgamOxYIYzP4UzLturdpFL6MBW6c9E0SdRy+Ydnb" + "SH40eSD+WGmkWgDhi8JDzJK2aIjAcTpjguEE"; InitializeComponent(); #region Init _logger = Service.GetInstance().GetLogger(); LibService.Init(_logger); LibService.GetInstance().SetDbConnectionString(Service.GetInstance().GetOpcDict()["DbConnectionString"]); AsLibraryCore.LibService.GetInstance().SetEventsDbConnectionString(Service.GetInstance().GetOpcDict()["EventsDbConnectionString"]); NewOpcServer.Init(_logger); NewOpcServer.GetInstance().InitOpc(NewOpcServer.OpcList.Rbu); NewOpcServer.GetInstance().ConnectOpc(NewOpcServer.OpcList.Rbu); var reportHelper = new ReportHelper(_logger); reportHelper.SubscribeReportSaving(); OpcServer.Init(@"Data/Service.xlsx"); OpcServer.GetInstance(); OpcServer.GetInstance().InitOpc(OpcServer.OpcList.Rbu, Service.GetInstance().GetOpcDict()["OpcServerAddress"]); OpcServer.GetInstance().ConnectOpc(OpcServer.OpcList.Rbu); EventsBase.GetInstance().CreateControlEvents(OpcServer.OpcList.Rbu); #endregion Title = ServiceData.GetInstance().GetTitle() + " " + Release.GetInstance().GetReleaseTitle(); Login(); EventsBase.GetInstance().GetControlEvents(OpcServer.OpcList.Rbu).AddEvent("Программа управления открыта", SystemEventType.Message); #region Масштаб экрана (comment) //var rect = SystemParameters.WorkArea; //if (rect.Width != 1920) // MainGrid.LayoutTransform = // new ScaleTransform(Math.Min(rect.Width, 1920) / 1920, Math.Min(rect.Height, 1080) / 1080); #endregion }