コード例 #1
0
        public async Task TestUploadFileAsync_Uploaded()
        {
            IAttachmentAppService factory(string id)
            {
                var appService = Substitute.For <IAttachmentAppService>();

                appService.GetByIdAsync(id)
                .ReturnsForAnyArgs(new AttachmentItem
                {
                    Id     = id,
                    Status = UploadStatus.Uploaded
                });
                return(appService);
            };
            var storeService = Substitute.For <IAttachmentStoreService>();
            var formFile     = Substitute.For <IFormFile>();
            var target       = new AttachmentController(factory, storeService,
                                                        Substitute.For <IMemoryCache>());
            var vm = new UploadVm
            {
                ContextId = Guid.Empty,
                File      = formFile,
                MD5       = Guid.NewGuid().ToString("N")
            };
            var result = await target.UploadFileAsync(vm);

            var responseData = result.Value;

            responseData.Data.Should().Be(UploadStatus.Uploaded);
            await storeService.DidNotReceiveWithAnyArgs().StoreFileAsync(vm, DateTimeOffset.UtcNow);
        }
コード例 #2
0
    public virtual IList <AttachmentController> DiscoverNearbyAttachable()
    {
        List <AttachmentController> nearby = new List <AttachmentController>();

        Collider[] hitColliders = Physics.OverlapSphere(transform.position, PullRadius);
        foreach (Collider collider in hitColliders)
        {
            PullableController pullable = collider.transform.GetComponent <PullableController>();
            if (pullable == null || pullable.CapturedBy != null)
            {
                continue;
            }

            AttachmentController attachment = collider.transform.GetComponent <AttachmentController>();
            if (attachment == null)
            {
                continue;
            }

            HardpointController mounting = attachment.FindMountingHardpoint();
            if (mounting == null || mounting.Attached != null)
            {
                continue;
            }

            nearby.Add(attachment);
        }
        return(nearby);
    }
コード例 #3
0
 public PullTogether(HardpointController point, AttachmentController attachment, HardpointController attachmentPoint)
 {
     Point              = point;
     Attachment         = attachment;
     AttachmentPoint    = attachmentPoint;
     AttachmentPullable = attachment.GetComponent <PullableController>();
 }
コード例 #4
0
    public virtual bool Detach(HardpointController point)
    {
        AttachmentController attachment = point.Attached;

        if (attachment == null)
        {
            return(false);
        }

        if (!attachment.OnDetach())
        {
            return(false);
        }

        FixedJoint[] joints = gameObject.GetComponents <FixedJoint>();
        foreach (FixedJoint joint in joints)
        {
            if (joint.connectedBody == attachment.rigidbody)
            {
                joint.connectedBody = null;
                Destroy(joint);
            }
        }

        point.Detach();
        attachment.rigidbody.AddForceAtPosition(point.transform.up * 10, point.transform.position);

        return(true);
    }
コード例 #5
0
    public IList <AttachmentController> DiscoverNearbyAttachable(float distance)
    {
        SensorController sensors = GetComponent <SensorController>();

        if (!sensors)
        {
            return(EmptyAttachments);
        }

        float dist2 = distance * distance;

        List <AttachmentController> result = new List <AttachmentController>();
        IDictionary <int, SensorController.Entry> sensorEntries = sensors.GetEntries();

        foreach (KeyValuePair <int, SensorController.Entry> pair in sensorEntries)
        {
            if (!pair.Value.Visible)
            {
                continue;
            }

            AttachmentController attachment = pair.Value.Object;
            Vector4 pos = attachment.transform.position;
            if (Vector4.Dot(pos, pos) > dist2)
            {
                continue;
            }

            result.Add(attachment);
        }
        return(result);
    }
コード例 #6
0
        private Page CreateNestedPage()
        {
            PageController pc       = new PageController();
            var            page     = pc.Create("page", testContext.users[0]);
            var            pageSub1 = pc.AddSubPage("sub page 1", page.Id, testContext.users[0]);
            var            pageSub2 = pc.AddSubPage("sub page 2", page.Id, testContext.users[0]);

            var p = pc.AddSubPage("sub 1 sub page 1", pageSub1.Id, testContext.users[0]);

            pc.ChangeOwner(p.Id, testContext.users[17].Id, testContext.users[0]);

            pc.AddSubPage("sub 2 sub page 1", pageSub2.Id, testContext.users[0]);

            var t = pc.AddAttachment("sub 1 attachment 1", pageSub1.Id, testContext.users[0]);
            AttachmentController ac = new AttachmentController();

            ac.ChangeOwner(t.Id, testContext.users[25].Id, testContext.users[0]);

            pc.AddAttachment("page attachment", page.Id, testContext.users[0]);

            var teams = CreateTeams();

            pc.AddAdmin(page.Id, teams[0].Id, testContext.users[0]);
            pc.AddReader(page.Id, teams[1].Id, testContext.users[0]);

            pc.AddAdmin(page.Id, testContext.users[10].Id, testContext.users[0]);
            pc.AddReader(page.Id, testContext.users[11].Id, testContext.users[0]);

            return(page);
        }
コード例 #7
0
 public Entry(AttachmentController obj, bool visible)
 {
     Object   = obj;
     Position = obj.transform.position;
     Visible  = visible;
     Name     = obj.name;
 }
コード例 #8
0
    public virtual void DiscoverNearby()
    {
        foreach (KeyValuePair <int, Entry> entry in Entries)
        {
            entry.Value.Visible = false;
        }

        Collider[] hitColliders = Physics.OverlapSphere(transform.position, Radius);
        foreach (Collider collider in hitColliders)
        {
            AttachmentController attachment = collider.transform.GetComponent <AttachmentController>();
            if (attachment == null)
            {
                continue;
            }

            bool       visible = false;
            RaycastHit hit;
            // If we don't hit any terrain then we'll assume that it is within sight.
            if (!Physics.Linecast(transform.position, attachment.transform.position, out hit, 1 << 11))
            {
                visible = true;
            }
            int id = attachment.gameObject.GetInstanceID();
            if (Entries.ContainsKey(id))
            {
                Entries[id].Update(visible);
            }
            else if (visible)
            {
                Entries[id] = new Entry(attachment, visible);
            }
        }
    }
コード例 #9
0
        public string getAttachedFilesByPostId(string PostId)
        {
            string SQL = @"SELECT [ID],[UserTitle],[FileTitle],[FileSize],[FileType],[PostId]
                        FROM [uDebate_Forum_Post_Files] where PostId=" + PostId;

            string sHTML = string.Empty;

            AttachmentController  cntAttachment = new AttachmentController();
            List <AttachmentInfo> lstFiles      = null;

            if (Convert.ToInt32(PostId) > 0)
            {
                lstFiles = cntAttachment.GetAllByPostID(Convert.ToInt32(PostId));
            }

            if (lstFiles.Count > 0)
            {
                sHTML += "<table class='attachments' cellspacing='0' cellpadding='0' width='160px'>";
                sHTML += "<td style='border-top: 1px solid #FDFDFD; padding:5px 3px;width:24px;'> <img src='" + ATC.Tools.GetParam("RootURL") +
                         @"DesktopModules/uDebate/images/s_attachment.png' align=middle'> </td> ";
                foreach (AttachmentInfo objFile in lstFiles)
                {
                    string strlink     = Common.Globals.LinkClick("FileID=" + objFile.FileID, PortalSettings.ActiveTab.TabID, ModuleId, false, true);
                    string strFileName = objFile.LocalFileName;
                    sHTML += @" <td style='border-top: 1px solid #FDFDFD; padding: 5px 0;'><a href='" + strlink + "'>"
                             + strFileName.Substring(0, Math.Min(strFileName.Length, 15)).ToLower() + @"</a>&nbsp;</td>";
                }
                sHTML += "</table>";
            }
            return(sHTML);
        }
コード例 #10
0
        /// <summary>
        /// Binds a list of files to a drop down list.
        /// </summary>
        /// <remarks></remarks>
        private void BindFileList()
        {
            lstAttachments.Items.Clear();

            AttachmentController  cntAttachment = new AttachmentController();
            List <AttachmentInfo> lstFiles      = null;

            if (PostId > 0)
            {
                lstFiles = cntAttachment.GetAllByPostID(PostId);
                //Check for "lost" uploads from previous uncompleted posts and add them to the list
                List <AttachmentInfo> lstTemp = cntAttachment.GetAllByUserID(UserId);
                if (lstTemp.Count > 0)
                {
                    lstFiles.AddRange(lstTemp);
                }
            }
            else
            {
                //Check for "lost" uploads from previous uncompleted posts and add them to the list
                lstFiles = cntAttachment.GetAllByUserID(UserId);
            }


            foreach (AttachmentInfo objFile in lstFiles)
            {
                ListItem lstItem = new ListItem();
                lstItem.Text  = objFile.LocalFileName;
                lstItem.Value = objFile.FileName;
                lstAttachments.Items.Add(lstItem);
                lstAttachmentIDs += objFile.AttachmentID.ToString() + ";";

                ViewState["attachment"] = objFile.AttachmentID;
            }
        }
コード例 #11
0
    protected void btnFile_Click(object sender, EventArgs e)
    {
        LinkButton button  = (LinkButton)sender;
        string     offerID = string.Empty;

        if (GXGridView1.SelectedValue != null)
        {
            offerID = GXGridView1.SelectedDataKey.Value.ToString();
        }
        else
        {
            offerID = GXGridView1SelectedValue.ToString();
        }
        string     destinationPath = OfferAttachmens_Directory + @"\" + offerID;
        string     file_path       = destinationPath + @"\" + button.Text;
        FileInfo   fi = new FileInfo(file_path);
        FileStream fs = fi.OpenRead();

        byte[] byte_get = new byte[fs.Length];
        fs.Read(byte_get, 0, byte_get.Length);
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.ClearContent();
        HttpContext.Current.Response.ClearHeaders();
        HttpContext.Current.Response.ContentType = AttachmentController.getMimeType(file_path);
        HttpContext.Current.Response.Charset     = string.Empty;
        HttpContext.Current.Response.Cache.SetCacheability(System.Web.HttpCacheability.Public);
        HttpContext.Current.Response.AddHeader("Content-Disposition:", "attachment; filename=" + button.Text);
        HttpContext.Current.Response.OutputStream.Write(byte_get, 0, byte_get.Length);
        HttpContext.Current.Response.OutputStream.Flush();
        HttpContext.Current.Response.OutputStream.Close();
        HttpContext.Current.Response.End();
    }
コード例 #12
0
        public async Task TestDownloadFileAsync()
        {
            var md5      = Guid.NewGuid().ToString("N");
            var formFile = Substitute.For <IFormFile>();

            var appService = Substitute.For <IAttachmentAppService>();

            IAttachmentAppService factory(string id) => appService;

            var storeService = Substitute.For <IAttachmentStoreService>();

            var target = new AttachmentController(factory, storeService,
                                                  Substitute.For <IMemoryCache>());

            target.ControllerContext = CreateMockContext();

            var result = await target.DownloadFileAsync(md5, null);

            result.Should().BeOfType <NotFoundResult>();

            appService.GetByIdAsync(md5)
            .Returns(new AttachmentItem
            {
                Id       = md5,
                Status   = UploadStatus.Uploading,
                Location = null
            });
            result = await target.DownloadFileAsync(md5, null);

            result.Should().BeOfType <NotFoundResult>();

            appService.GetByIdAsync(md5)
            .Returns(new AttachmentItem
            {
                Id       = md5,
                Status   = UploadStatus.Uploaded,
                Location = null
            });
            result = await target.DownloadFileAsync(md5, null);

            result.Should().BeOfType <NotFoundResult>();

            var dto = new AttachmentItem
            {
                Id       = md5,
                Status   = UploadStatus.Uploaded,
                Location = "abc.ext"
            };

            appService.GetByIdAsync(md5)
            .Returns(dto);
            storeService.FillMemoryStreamAsync(dto, Arg.Any <MemoryStream>())
            .Returns(Task.CompletedTask);
            result = await target.DownloadFileAsync(md5, null);

            result.Should().BeOfType <FileStreamResult>();

            await storeService.Received().FillMemoryStreamAsync(dto, Arg.Any <MemoryStream>());
        }
コード例 #13
0
 public virtual void DestroyAttachment()
 {
     ParentAttachment = null;
     foreach (HardpointController hardpoint in MountingHardpoints)
     {
         hardpoint.Detach();
     }
 }
コード例 #14
0
 public AttachmentControllerTests()
 {
     _fileUploadConfig = new FileUploadConfigModel
     {
         AllowedExtensions = new List <string> {
             ".pdf", ".docx"
         }
     };
     _sut = new AttachmentController(_mockAttachmentsService, _mockSessionService, _fileUploadConfig);
 }
コード例 #15
0
        public void AddJDBLogo(int x_position, int y_position)
        {
            string physicalPath        = AttachmentController.ApplicationPath();
            string imageDirectoryPath  = physicalPath + @"\_assets\img\imgInApp\";
            BrokerHouseInformation bhi = BrokerHouseInformation.GetInformation();
            string imagePath           = imageDirectoryPath + bhi.BrokerHouseLogoRelativeUrl;
            Image  image = Image.GetInstance(imagePath);

            image.SetAbsolutePosition(x_position, y_position);
            doc.Add(image);
        }
コード例 #16
0
        /// <summary>
        /// When the control is loaded, we want to make sure the cmdUpload is registered for postback because of the nature of the file upload control and security.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks></remarks>
        protected void Page_Load(object sender, System.EventArgs e)
        {
            //Localization (needed because of AJAX)
            cmdDelete.ToolTip = Localization.GetString("Delete", this.LocalResourceFile);
            cmdUpload.Text    = Localization.GetString("Upload", this.LocalResourceFile);
            //plUpload.Text = Localization.GetString("plUpload", this.LocalResourceFile) + ":";
            //plUpload.HelpText = Localization.GetString("plUpload.Help", this.LocalResourceFile);
            //plAttachments.Text = Localization.GetString("plAttachments", this.LocalResourceFile) + ":";
            //plAttachments.HelpText = Localization.GetString("plAttachments.Help", this.LocalResourceFile);

            // We can only delete files while not in use, look for Items to be deleted (PostID set to -2)
            if (Page.IsPostBack == false)
            {
                AttachmentController  cntAttachment  = new AttachmentController();
                List <AttachmentInfo> lstAttachments = cntAttachment.GetAllByPostID(-2);
                if (lstAttachments.Count > 0)
                {
                    foreach (AttachmentInfo objFile in lstAttachments)
                    {
                        DeleteItems += objFile.FileName + ";";
                    }
                }
            }
            else
            {
                //Delete any files set for deletion

                if (DeleteItems != string.Empty)
                {
                    string ParentFolderName = PortalSettings.HomeDirectoryMapPath;
                    ParentFolderName += BaseFolder;
                    ParentFolderName  = ParentFolderName.Replace("/", "\\");
                    if (ParentFolderName.EndsWith("\\") == false)
                    {
                        ParentFolderName += "\\";
                    }

                    char[]   splitter = { ';' };
                    string[] Array    = DeleteItems.Split(splitter);

                    foreach (string item in Array)
                    {
                        if (item != string.Empty)
                        {
                            DotNetNuke.Common.Utilities.FileSystemUtils.DeleteFile(ParentFolderName + item, PortalSettings, true);
                            // Remove the filename from DeleteItems.
                            // If it was not deleted, it will be picked up next time
                            DeleteItems = DeleteItems.Replace(item + ";", "");
                        }
                    }
                }
            }
        }
コード例 #17
0
        public void AddJDBLogoForFactures(int x_position, int y_position)
        {
            string physicalPath       = AttachmentController.ApplicationPath();
            string imageDirectoryPath = physicalPath + @"\_assets\img\imgInApp\";
            string fileName           = @"euromak_td.png";
            //BrokerHouseInformation bhi = BrokerHouseInformation.GetInformation();
            string imagePath = imageDirectoryPath + fileName;
            Image  image     = Image.GetInstance(System.Drawing.Image.FromFile(imagePath), System.Drawing.Imaging.ImageFormat.Png);

            image.ScaleToFit(220f, 138f);
            image.SetAbsolutePosition(x_position, y_position);
            doc.Add(image);
        }
コード例 #18
0
        public void GetAttachmentById_Test()
        {
            var controller = new AttachmentController(_unit);

            controller.Request       = new HttpRequestMessage();
            controller.Configuration = new HttpConfiguration();
            var response = controller.GetAttachmentByID(69);

            AttachmentDTO attachment;

            Assert.IsNotNull(response);
            Assert.IsTrue(response.TryGetContentValue <AttachmentDTO>(out attachment));
        }
コード例 #19
0
 public void Detach()
 {
     if (Attached != null)
     {
         Attached.ParentAttachment = null;
         Attached = null;
     }
     if (AttachedPoint != null)
     {
         AttachedPoint.Attached      = null;
         AttachedPoint.AttachedPoint = null;
         AttachedPoint = null;
     }
 }
コード例 #20
0
    public virtual bool Detach(HardpointController point, bool ignore)
    {
        AttachmentController attachment = point.Attached;

        if (Detach(point))
        {
            if (ignore)
            {
                IgnoreAttachments[attachment.GetInstanceID()] = attachment;
            }
            return(true);
        }
        return(false);
    }
コード例 #21
0
    public void Fire(params IList <HardpointController>[] hardpoints)
    {
        if (BulletPrefab == null || NextFire > Time.time)
        {
            return;
        }
        NextFire = Time.time + Cooldown;
        foreach (IList <HardpointController> list in hardpoints)
        {
            foreach (HardpointController obj in list)
            {
                Vector3          position   = obj.transform.position + obj.transform.forward * 1.0f;
                GameObject       newBullet  = Instantiate(BulletPrefab, position, obj.transform.rotation) as GameObject;
                BulletController controller = newBullet.GetComponent <BulletController>();
                if (controller != null)
                {
                    controller.Owner = this;
                }
                // Bullets along the direction vector get a speed boost.
                Vector3 speedBoost = Vector3.Project(rigidbody.velocity, obj.transform.forward);

                Vector3 velo = obj.transform.forward * BulletSpeed + speedBoost;
                newBullet.rigidbody.velocity = velo;

                // Bullets cannot collide with the gun that fired it.
                if (collider != null)
                {
                    Physics.IgnoreCollision(newBullet.collider, collider);
                }

                // Bullets also do not collide with the attachment chain that fired it.
                // This could be changed to a distance or timer so that it can collide
                // but not immediately after being fired.
                AttachmentController parent = ParentAttachment;
                while (parent != null)
                {
                    if (parent.collider != null)
                    {
                        Physics.IgnoreCollision(newBullet.collider, parent.collider);
                    }
                    parent = parent.ParentAttachment;
                }
            }
        }
        if (FireClip != null)
        {
            audio.PlayOneShot(FireClip);
        }
    }
コード例 #22
0
    public virtual bool IsParentOf(AttachmentController attachment)
    {
        if (attachment == this)
        {
            return(true);
        }

        AttachmentController parent = attachment.ParentAttachment;

        while (parent != null && parent != this)
        {
            parent = parent.ParentAttachment;
        }
        return(parent == this);
    }
コード例 #23
0
    public override bool Attach(HardpointController point, AttachmentController attachment, HardpointController attachmentPoint)
    {
        bool result = base.Attach(point, attachment, attachmentPoint);

        if (result)
        {
            if (FlightComputer != null)
            {
                EngineController engine = attachment as EngineController;
                if (engine != null)
                {
                    FlightComputer.AddEngine(engine);
                }
            }
        }
        return(result);
    }
コード例 #24
0
    public virtual void DiscoverConnected(bool clearCurrent = false)
    {
        if (clearCurrent)
        {
            ConnectedAttachments.Clear();
            AttachmentGroups.Clear();
            AttachmentTypes.Clear();
        }

        Joint[] connected = transform.GetComponentsInChildren <Joint>();
        for (int i = 0; i < connected.Length; i++)
        {
            Rigidbody other = connected[i].connectedBody;
            if (other != null)
            {
                //DiscoverConnected(other.transform);
                AttachmentController [] attachments = other.transform.GetComponentsInChildren <AttachmentController>();
                for (int j = 0; j < attachments.Length; j++)
                {
                    AttachmentController attachment = attachments[j];
                    string group    = attachment.AttachmentGroup;
                    string type     = attachment.AttachmentType;
                    bool   newGroup = !AttachmentGroups.ContainsKey(group);
                    bool   newType  = !AttachmentTypes.ContainsKey(type);
                    if (!OnDiscoverNewAttachment(attachment, newType, newGroup))
                    {
                        continue;
                    }
                    ConnectedAttachments[attachment.GetInstanceID()] = attachment;
                    if (newGroup)
                    {
                        AttachmentGroups[group] = new List <AttachmentController>();
                    }
                    if (newType)
                    {
                        AttachmentTypes[type] = new List <AttachmentController>();
                    }
                    AttachmentGroups[group].Add(attachment);
                    AttachmentTypes[type].Add(attachment);
                }
            }
        }

        CalculateCenterOfMass();
    }
コード例 #25
0
        public ControllerTest()
        {
            var services = new ServiceCollection();
            var config   = InitConfiguration();

            services.AddDbContext <Inlook_Context>(
                options => options.UseSqlServer(config.GetConnectionString("DefaultConnection")));

            services.AddScoped <IAttachmentService, AttachmentService>();
            services.AddScoped <IGroupService, GroupService>();
            services.AddScoped <IMailService, MailService>();
            services.AddScoped <IRoleService, RoleService>();
            services.AddScoped <IUserService, UserService>();
            services.AddScoped <INotificationService, NotificationService>();
            services.AddSingleton(x =>
                                  new BlobServiceClient(config.GetValue <string>("AzureStorageBlobConnectionString")));

            //var serviceProvider = services.BuildServiceProvider();
            var serviceProvider = services
                                  .AddLogging()
                                  .BuildServiceProvider();
            var factory = serviceProvider.GetService <ILoggerFactory>();

            this._logger = factory.CreateLogger <BaseController>();

            TelemetryConfiguration configuration = new TelemetryConfiguration();

            configuration.InstrumentationKey = userId.ToString();
            configuration.TelemetryInitializers.Add(new OperationCorrelationTelemetryInitializer());
            this._telemetryClient = new TelemetryClient(configuration);

            this.attachmentService   = serviceProvider.GetService <IAttachmentService>();
            this.groupService        = serviceProvider.GetService <IGroupService>();
            this.mailService         = serviceProvider.GetService <IMailService>();
            this.userService         = serviceProvider.GetService <IUserService>();
            this.notificationService = serviceProvider.GetService <INotificationService>();
            this.dbContext           = serviceProvider.GetService <Inlook_Context>();

            this.notificationController = new NotificationController(this.notificationService);
            this.userController         = new UserController(factory.CreateLogger <UserController>(), this._telemetryClient, this.userService);
            this.mailController         = new MailController(factory.CreateLogger <MailController>(), this._telemetryClient, this.mailService, this.userService);
            this.groupController        = new GroupController(factory.CreateLogger <GroupController>(), this._telemetryClient, this.groupService);
            this.attachmentController   = new AttachmentController(factory.CreateLogger <AttachmentController>(), this._telemetryClient, this.attachmentService);
        }
コード例 #26
0
        /// <summary>
        /// Setup the test
        /// </summary>
        public AttachmentApiUnitTest()
        {
            DbContextOptions <DbAppContext> options      = new DbContextOptions <DbAppContext>();
            Mock <DbAppContext>             dbAppContext = new Mock <DbAppContext>(null, options);

            /*
             *
             * Here you will need to mock up the context.
             *
             * ItemType fakeItem = new ItemType(...);
             *
             * Mock<DbSet<ItemType>> mockList = MockDbSet.Create(fakeItem);
             *
             * dbAppContext.Setup(x => x.ModelEndpoint).Returns(mockItem.Object);
             *
             */

            AttachmentService _service = new AttachmentService(dbAppContext.Object);

            _AttachmentApi = new AttachmentController(_service);
        }
コード例 #27
0
    void FixedUpdate()
    {
        if (this == null)
        {
            return;
        }
        Vector3    newPosition = transform.position + rigidbody.velocity * Time.fixedDeltaTime;
        RaycastHit hit;

        if (Physics.Linecast(transform.position, newPosition, out hit))
        {
            if (hit.collider.gameObject != Owner.gameObject)
            {
                AttachmentController isAttachment = hit.collider.GetComponent <AttachmentController>();
                if (isAttachment == null || !isAttachment.IsParentOf(Owner))
                {
                    OnCollision(hit.collider, hit.point, hit.normal);
                }
            }
        }
    }
コード例 #28
0
        public async Task TestGetStatusAsync()
        {
            IAttachmentAppService factory(string id)
            {
                var appService = Substitute.For <IAttachmentAppService>();

                appService.GetByIdAsync(id)
                .ReturnsForAnyArgs(new AttachmentItem
                {
                    Id     = id,
                    Status = UploadStatus.Uploaded
                });
                return(appService);
            };
            var target = new AttachmentController(factory, Substitute.For <IAttachmentStoreService>(),
                                                  Substitute.For <IMemoryCache>());
            var result = await target.GetStatusAsync(Guid.NewGuid().ToString("N"));

            var data = result.Value;

            data.Should().Be(UploadStatus.Uploaded);
        }
コード例 #29
0
ファイル: NewsRepository.cs プロジェクト: jimeneza14/R7.News
        // TODO: Can use IEnumerable here
        static void UpdateContentItem(ContentItem contentItem, NewsEntryInfo newsEntry, List <Term> terms, List <IFileInfo> images)
        {
            // update content item after EntryId get its value
            // TODO: ContentKey should allow users to view your content item directly based on links provided from the tag search results
            // more info here: http://www.dnnsoftware.com/community-blog/cid/131963/adding-core-taxonomy-to-your-module-part-2-ndash-content-items
            contentItem.ContentKey = newsEntry.EntryId.ToString();
            NewsDataProvider.Instance.ContentController.UpdateContentItem(contentItem);

            // add images to content item
            if (images.Count > 0)
            {
                var attachmentController = new AttachmentController(NewsDataProvider.Instance.ContentController);
                attachmentController.AddImagesToContent(contentItem.ContentItemId, images);
            }

            // add terms to content item
            var termController = new TermController();

            foreach (var term in terms)
            {
                termController.AddTermToContent(term, contentItem);
            }
        }
コード例 #30
0
        public void TestElectrocardiogramUploadValid()
        {
            //Arrange
            Mock <IAttachmentRepository> attachmentRepository = new Mock <IAttachmentRepository>();
            AttachmentController         controller           = new AttachmentController(attachmentRepository.Object);
            string fileName = "file.pdf";
            var    stream   = new MemoryStream(new byte[] { 1, 2, 3, 4 });
            Mock <HttpPostedFile> httpFile = new Mock <HttpPostedFile>();

            httpFile.SetupGet(f => f.FileName).Returns(fileName);


            var args = new FileUploadCompleteEventArgs(
                string.Empty,
                true,
                string.Empty,
                new UploadedFile(httpFile.Object));

            //Act
            controller.OnElectrocardiogramUploadComplete(null, args);

            //Assert
        }
コード例 #31
0
 public static AttachmentController Fixture()
 {
     AttachmentController controller = new AttachmentController(new AttachmentRepository(), "", new LoginView());
     return controller;
 }