public NewConsumer(frmNew frmNew)
        {
            New = frmNew ?? throw new ArgumentNullException(nameof(frmNew));
            IProjectDataFactory        projectFactory = new ProjectDataFactory();
            ISubTranslationDataFactory subFactory     = new SubTranslationDataFactory();

            translationDataFactory = new TranslationDataFactory(projectFactory, subFactory);
        }
Beispiel #2
0
        public HubConsumer(FrmHub frmHub)
        {
            Hub = frmHub ?? throw new ArgumentNullException(nameof(frmHub));
            IProjectDataFactory        projectFactory     = new ProjectDataFactory();
            ISubTranslationDataFactory subFactory         = new SubTranslationDataFactory();
            ITranslationDataFactory    translationFactory = new TranslationDataFactory(projectFactory, subFactory);

            fileRepository = new FileRepository(translationFactory);
        }
Beispiel #3
0
        public ActionResult Dashboard(OnlineTranslationRequest translationRequest, string submit)
        {
            ITranslationData           data = null;
            IProjectDataFactory        projectDataFactory        = new ProjectDataFactory();
            ISubTranslationDataFactory subTranslationDataFactory = new SubTranslationDataFactory();
            ITranslationDataFactory    translationDataFactory    = new TranslationDataFactory(projectDataFactory, subTranslationDataFactory);
            IFileRepository            fileRepository            = new FileRepository(translationDataFactory);

            switch (submit)
            {
            case "Open":

                if (Request.Files.Count > 0 && Request.Files[0].FileName.Any())
                {
                    var file = Request.Files[0];
                    if (file != null & file.ContentLength > 0)
                    {
                        var fileName = Path.GetFileName(file.FileName);
                        var fileType = Path.GetExtension(fileName);
                        // Need to treat this at some point
                        var filePath = @"C:\Temp\" + fileName;
                        file.SaveAs(filePath);

                        var openData = fileRepository.OpenFile(fileType, filePath, fileName);
                        data = openData.Item1;
                    }
                }
                else
                {
                    throw new Exception("No requests.");
                }

                break;

            case "Create":

                if (translationRequest != null)
                {
                    string       fileName = translationRequest.ProjectName;
                    string[]     rawData  = translationRequest.RawData.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
                    IProjectData project  = projectDataFactory.CreateProjectDataFromArray(fileName, rawData);
                    data = translationDataFactory.CreateTranslationDataFromProject(project);
                }
                else
                {
                    throw new Exception("No requests.");
                }

                break;

            default:
                break;
            }

            System.Web.HttpContext.Current.Session["ProjectData"] = data.GetProjectData();
            return(View());
        }
Beispiel #4
0
            public void ProjectDataFactory_DefaultConstructor_Test()
            {
                //Arrange
                var expected = new ProjectDataFactory();

                //Act
                var actual = new ProjectDataFactory();

                //Assert
                Assert.IsType <ProjectDataFactory>(actual);
                Assert.IsAssignableFrom <IProjectDataFactory>(actual);
                Assert.NotStrictEqual(expected, actual);
            }