public void GetInvoiceTest() { IDataFiller constantDataFiller = new ConstantDataFiller(); IDataRepository dataRepository = new DataRepositoryForTest(constantDataFiller); IDataService dataService = new DataService(dataRepository); Invoice presentInvoice = dataRepository.GetEvent(2) as Invoice; Client presentInvoiceClient = presentInvoice.Client; CopyDetails presentInvoiceCopyDetails = presentInvoice.CopyDetails; DateTime presentInvoicePurchaseTime = presentInvoice.EventDateTime; String presentInvoiceDescription = presentInvoice.Description; Invoice notPresentInvoice = new Invoice(dataRepository.GetClient(2), dataRepository.GetCopyDetails(3), new DateTime(2040, 2, 2), "description"); Assert.Equal(presentInvoice, dataService.GetInvoice(presentInvoiceClient, presentInvoiceCopyDetails, presentInvoicePurchaseTime, presentInvoiceDescription)); try { Assert.NotEqual(notPresentInvoice, dataService.GetInvoice(dataRepository.GetClient(2), dataRepository.GetCopyDetails(3), new DateTime(2040, 2, 2), "description")); } catch (ArgumentException) { } }
public void copyProject(IFCProjectInfo ProjectInfo, string Export, CopyDetails IFCInfo) { foreach (var Folder in ProjectInfo.Folders) { if (Folder.Export == Export || Folder.Export == "") { string IFCPath = IFCInfo.To + "\\" + Export + ".ifc"; //Sjekker om det er en eksisterende ifc og sletter den if (File.Exists(IFCPath)) { File.Delete(IFCPath); } //Kopierer inn ny tom.ifc FileInfo file = new FileInfo(IFCInfo.From); file.CopyTo(IFCPath, true); //Kopierer Modellfilene for gjeldende f*g DirectoryCopy(Folder.From, Folder.To, true); } } //Kopierer eventuelle enkeltstående filer som f.eks. mep- og QPD-filer. Hvis "Export" attributten står tom skal denne kopieres hver gang. foreach (var File in ProjectInfo.Files) { if (File.Export == Export || File.Export == "") { FileInfo file = new FileInfo(File.From); file.CopyTo(File.To, true); } } }
public void DeleteCopyDetailsForbiddenTest() { IDataFiller constantDataFiller = new ConstantDataFiller(); IDataRepository dataRepository = new DataRepository(constantDataFiller); CopyDetails copyDetails = (dataRepository.GetEvent(0) as Invoice).CopyDetails; Assert.Throws <ArgumentException>(() => dataRepository.DeleteCopyDetails(copyDetails)); }
public ViewModelMain() { SelectSourceDirectoryCommand = new RelayCommand(SelectSourceDirectory); SelectDestinationDirectoryCommand = new RelayCommand(SelectDestinationDirectory); EngageCopyCommand = new RelayCommand(EngageCopy); CopyDetails = new CopyDetails(); }
UpdateBookStock(CopyDetails copyDetails, int count) { if (count < 0) { throw new InvalidOperationException("You can't update book stock with negative number."); } copyDetails.Count = count; _dataRepository.UpdateCopyDetails(copyDetails, _dataRepository.FindCopyDetails(copyDetails)); }
public void CopyDetailsTest() { Book b1 = new Book("Year 1984", "George Orwell", 1949); CopyDetails cd1 = new CopyDetails(b1, new decimal(35.99), new decimal(2.65), 1, "short description"); Assert.Equal(b1, cd1.Book); Assert.Equal(new decimal(35.99), cd1.Price); Assert.Equal(new decimal(2.65), cd1.Tax); Assert.Equal(1, cd1.Count); }
public void UpdateBookStockTest() { IDataFiller constantDataFiller = new ConstantDataFiller(); IDataRepository dataRepository = new DataRepositoryForTest(constantDataFiller); IDataService dataService = new DataService(dataRepository); CopyDetails copyDetails = dataRepository.GetCopyDetails(0); dataService.UpdateBookStock(copyDetails, 1); Assert.Equal(1, dataRepository.GetCopyDetails(0).Count); }
public void FindCopyDetailsInvalidValueTest() { IDataFiller constantDataFiller = new ConstantDataFiller(); IDataRepository dataRepository = new DataRepository(constantDataFiller); Book b1 = new Book("Year 1984", "George Orwell", 1949); CopyDetails cd1 = new CopyDetails(b1, new decimal(35.99), new decimal(2.65), 1, "short description"); Assert.Throws <ArgumentException>(() => (dataRepository.FindCopyDetails(cd1)) as object); }
public void InvoiceTest() { DateTime purchaseTime = DateTime.Now; Book b1 = new Book("Year 1984", "George Orwell", 1949); Client c1 = new Client("*****@*****.**", "John", "Smith", "896-457-891"); CopyDetails cd1 = new CopyDetails(b1, new decimal(35.99), new decimal(2.65), 1, "short description"); Invoice inv1 = new Invoice(c1, cd1, purchaseTime, "description"); Assert.Equal(c1, inv1.Client); Assert.Equal(cd1, inv1.CopyDetails); Assert.Equal(purchaseTime, inv1.EventDateTime); }
public void GetCopyDetailsValidValue() { IDataFiller constantDataFiller = new ConstantDataFiller(); IDataRepository dataRepository = new DataRepository(constantDataFiller); Book b1 = new Book("Year 1984", "George Orwell", 1949); CopyDetails cd1 = new CopyDetails(b1, new decimal(35.99), new decimal(2.65), 1, "short description"); dataRepository.AddCopyDetails(cd1); Assert.NotNull(dataRepository.GetCopyDetails(dataRepository.FindCopyDetails(cd1))); }
public void DeleteCopyDetailsInvalidValueTest() { IDataFiller constantDataFiller = new ConstantDataFiller(); IDataRepository dataRepository = new DataRepository(constantDataFiller); Book b1 = new Book("Year 1984", "George Orwell", 1949); CopyDetails cd1 = new CopyDetails(b1, new decimal(35.99), new decimal(2.65), 1, "short description"); Assert.Equal(5, dataRepository.GetAllCopyDetails().Count()); Assert.Throws <ArgumentException>(() => dataRepository.DeleteCopyDetails(cd1)); }
public void FindClientCopyDetailsValueTest() { IDataFiller constantDataFiller = new ConstantDataFiller(); IDataRepository dataRepository = new DataRepository(constantDataFiller); Book b1 = new Book("Year 1984", "George Orwell", 1949); CopyDetails cd1 = new CopyDetails(b1, new decimal(35.99), new decimal(2.65), 1, "short description"); dataRepository.AddCopyDetails(cd1); Assert.StrictEqual(5, dataRepository.FindCopyDetails(cd1)); }
public CopyDetails GetIFCFileData(IFCProjectInfo ProjectInfo) { CopyDetails currentIFC = new CopyDetails(); foreach (var File in ProjectInfo.Files) { if (File.Export == "tomIFC") { currentIFC = File; } } return(currentIFC); }
public void AddCopyDetailsValidValueTest() { IDataFiller constantDataFiller = new ConstantDataFiller(); IDataRepository dataRepository = new DataRepository(constantDataFiller); Book b1 = new Book("Year 1984", "George Orwell", 1949); CopyDetails cd1 = new CopyDetails(b1, new decimal(35.99), new decimal(2.65), 1, "short description"); dataRepository.AddCopyDetails(cd1); Assert.Equal(6, dataRepository.GetAllCopyDetails().Count()); Assert.Equal(cd1, dataRepository.GetCopyDetails(5)); }
public void UpdateCopyDetailsTest() { IDataFiller constantDataFiller = new ConstantDataFiller(); IDataRepository dataRepository = new DataRepositoryForTest(constantDataFiller); IDataService dataService = new DataService(dataRepository); CopyDetails copyDetails = dataRepository.GetCopyDetails(0); copyDetails.Count = 999; dataService.UpdateCopyDetails(copyDetails); Assert.Equal(999, dataService.GetAllCopyDetails().First().Count); }
public void AddCopyDetailsTest() { IDataFiller constantDataFiller = new ConstantDataFiller(); IDataRepository dataRepository = new DataRepositoryForTest(constantDataFiller); IDataService dataService = new DataService(dataRepository); CopyDetails copyDetails = new CopyDetails(dataRepository.GetBook(3), 15.60m, 2.60m, 2, "Sample book invoice"); int copyDetailsNumber = dataService.GetAllCopyDetails().ToImmutableHashSet().Count; dataService.AddCopyDetails(copyDetails); Assert.Equal(copyDetailsNumber + 1, dataService.GetAllCopyDetails().ToImmutableHashSet().Count); Assert.Equal(copyDetails, dataService.GetAllCopyDetails().Last()); }
public override bool Equals(object?obj) { if ((obj == null) || !this.GetType().Equals(obj.GetType())) { return(false); } else { CopyDetails cd = (CopyDetails)obj; return((this.Book.Equals(cd.Book)) && (this.Price.Equals(cd.Price)) && (this.Tax.Equals(cd.Tax)) && (this.Count.Equals(cd.Count)) && (this.Description.Equals(cd.Description))); } }
public Invoice BuyBook(Client client, CopyDetails copyDetails, string description) { if (copyDetails.Count <= 0) { throw new InvalidOperationException("We don't have these books, wait for book stock updating."); } Invoice createdInvoice = new Invoice(client, copyDetails, DateTime.Now, description); copyDetails.Count -= 1; _dataRepository.UpdateCopyDetails(copyDetails, this._dataRepository.FindCopyDetails(copyDetails)); _dataRepository.AddEvent(createdInvoice); return(createdInvoice); }
public void BuyBookTest() { IDataFiller constantDataFiller = new ConstantDataFiller(); IDataRepository dataRepository = new DataRepositoryForTest(constantDataFiller); IDataService dataService = new DataService(dataRepository); Client client = dataRepository.GetClient(2); CopyDetails copyDetails = dataRepository.GetCopyDetails(3); int originalCopyDetailsCount = copyDetails.Count; int totalInvoices = dataRepository.GetAllEvents().ToImmutableHashSet().Count; dataService.BuyBook(client, copyDetails, "description"); Assert.Equal(originalCopyDetailsCount - 1, dataRepository.GetCopyDetails(3).Count); Assert.Equal(totalInvoices + 1, dataRepository.GetAllEvents().ToImmutableHashSet().Count); }
public void UpdateCopyDetailsInvalidValueTest() { IDataFiller constantDataFiller = new ConstantDataFiller(); IDataRepository dataRepository = new DataRepository(constantDataFiller); Book b1 = new Book("Year 1984", "George Orwell", 1949); CopyDetails cd1 = new CopyDetails(b1, new decimal(35.99), new decimal(2.65), 1, "short description"); dataRepository.AddCopyDetails(cd1); Assert.Equal("short description", dataRepository.GetCopyDetails(5).Description); cd1.Description = "long description"; Assert.Throws <ArgumentException>(() => dataRepository.UpdateCopyDetails(cd1, 105)); }
public void DeleteCopyDetailsTest() { IDataFiller constantDataFiller = new ConstantDataFiller(); IDataRepository dataRepository = new DataRepositoryForTest(constantDataFiller); IDataService dataService = new DataService(dataRepository); CopyDetails copyDetails = new CopyDetails(dataRepository.GetBook(2), 15.6m, 2.30m, 1, "Sample invoice"); dataService.AddCopyDetails(copyDetails); int originalCount = dataService.GetAllCopyDetails().ToImmutableHashSet().Count; dataService.DeleteCopyDetails(copyDetails); Assert.Equal(originalCount - 1, dataService.GetAllCopyDetails().ToImmutableHashSet().Count); Assert.DoesNotContain(copyDetails, dataService.GetAllCopyDetails()); }
public void GetCopyDetailsTest() { IDataFiller constantDataFiller = new ConstantDataFiller(); IDataRepository dataRepository = new DataRepositoryForTest(constantDataFiller); IDataService dataService = new DataService(dataRepository); CopyDetails presentCopyDetails = dataRepository.GetCopyDetails(3); Book book = presentCopyDetails.Book; decimal price = presentCopyDetails.Price; decimal tax = presentCopyDetails.Tax; int count = presentCopyDetails.Count; String description = presentCopyDetails.Description; CopyDetails notPresentCopyDetails = new CopyDetails(book, price, tax, 50, "There is no such description"); Assert.Equal(presentCopyDetails, dataService.GetCopyDetails(book, price, tax, count, description)); Assert.DoesNotContain(notPresentCopyDetails, dataService.GetAllCopyDetails()); }
public void Fill(DataContext dataContext) { Random random = new Random(); for (int i = 0; i < clientNumber; i++) { Client client = new Client( GenerateRandomString(8) + "@" + GenerateRandomString(3) + ".com", GenerateRandomString(5), GenerateRandomString(5), GenerateNumberString(8)); dataContext.Clients.Add(client); } for (int i = 0; i < bookNumber; i++) { Book book = new Book(GenerateRandomString(8), GenerateRandomString(10), random.Next(1900, 2020) ); dataContext.Books.Add(i, book); CopyDetails copyDetails = new CopyDetails( book, (decimal)random.NextDouble(), (decimal)random.NextDouble(), random.Next(), GenerateRandomString(5) ); dataContext.AllCopyDetails.Add(copyDetails); } for (int i = 0; i < invoiceNumber; i++) { Invoice invoice = new Invoice( dataContext.Clients[random.Next(0, clientNumber)], dataContext.AllCopyDetails[random.Next(0, copyDetailsNumber)], new DateTime(random.Next(2000, 2020), random.Next(1, 12), random.Next(1, 28)), GenerateRandomString(8) ); dataContext.Events.Add(invoice); } }
public void IFCEXPORT() { string StoredProjectsFolder = "C:\\IFCEXPORT\\XML"; string SelectedProject = "MH2"; string SelectedProjectPath = getSelectedProjectPath(SelectedProject, Directory.GetFiles(StoredProjectsFolder)); var ProjectInfo = GetprojectInfo(SelectedProjectPath); CopyDetails IFCInfo = GetIFCFileData(ProjectInfo); foreach (var StartFile in ProjectInfo.StartFiles) { foreach (var Folder in ProjectInfo.Folders) { if (Folder.Discipline == StartFile.Discipline) { copyProject(ProjectInfo, Folder.Export, IFCInfo); } } DM.OPENDRAWING(StartFile.Path); DM.ACTIVATEDRAWING(StartFile.Path); acDoc = Application.DocumentManager.MdiActiveDocument; foreach (var Folder in ProjectInfo.Folders) { if (Folder.Discipline == StartFile.Discipline) { acDoc.Editor.Command(new object[] { "._circle", "2,2,0", 4 }); acDoc.Editor.Command(new object[] { "_-MAGIIFCEXPORT", Folder.Export }); //acDoc.SendStringToExecute("-MAGIIFC" + " ", true, false, true); //acDoc.SendStringToExecute(Folder.Export + "\n", true, false, true); FileInfo file = new FileInfo(IFCInfo.To + "\\" + Folder.Export + ".ifc"); file.CopyTo(Path.GetDirectoryName(IFCInfo.From) + "\\" + Folder.Export + ".ifc", true); System.Windows.MessageBox.Show(acDoc.Name); } } DM.CLOSEDRAWING(StartFile.Path); } }
private void EngageCopy(object obj) { MessageBox.Show(CopyDetails.ToString()); }
public void DeleteCopyDetails(CopyDetails copyDetails) { _dataRepository.DeleteCopyDetails(copyDetails); }
public void UpdateCopyDetails(CopyDetails copyDetails) { _dataRepository.UpdateCopyDetails(copyDetails, _dataRepository.FindCopyDetails(copyDetails)); }
public Invoice GetInvoice(Client client, CopyDetails copyDetails, DateTime eventDateTime, string description) { return(_dataRepository.GetEvent( _dataRepository.FindEvent(new Invoice(client, copyDetails, eventDateTime, description))) as Invoice); }
public void AddCopyDetails(CopyDetails copyDetails) { _dataRepository.AddCopyDetails(copyDetails); }