Example #1
0
        //LAYER_Class_NameOfTheMethod_TestedScenario_ExpectedBehaviour
        public void MODEL_Upload_FullConstructor_CreateFileUpload_FileUploadIsCreated()
        {
            //arrange
            int uploadId = 6;

            Text text = null;

            File file = new File();
            file.fileId = 2;

            //act
            Upload upload_m2 = new Upload(
                uploadId,
                text,
                file
                );

            //assert
            Assert.IsNotNull(upload_m2, "upload object is null");
            Assert.AreEqual(6, upload_m2.uploadId, "wrong uploadId");

            Assert.IsNull(upload_m2.text, "upload.text is NOT null");

            Assert.IsNotNull(upload_m2.file, "upload.file object is null");
            Assert.AreEqual(2, upload_m2.file.fileId, "wrong upload.file.fileId");            
        }
Example #2
0
 //full constructor
 internal Upload(
     int uploadId,
     Text text,
     File file
     )
 {
     this.uploadId = uploadId;
     this.text = text;
     this.file = file;
 }
Example #3
0
        //LAYER_Class_NameOfTheMethod_TestedScenario_ExpectedBehaviour
        public void MODEL_File_FullConstructor_CreateFile_FileIsCreated()
        {
            //arrange
            int fileId = 1;

            //act
            File file_m1 = new File(
                fileId
                );

            //assert
            Assert.IsNotNull(file_m1, "file object is null");
            Assert.AreEqual(1, file_m1.fileId, "wrong fileId");
        }
Example #4
0
        //LAYER_Class_NameOfTheMethod_TestedScenario_ExpectedBehaviour
        public void MODEL_File_SetAndGetMethods_ModifyAllFieldsValues_AllValuesAreModified()
        {
            //arrange
            int fileId = 1;
            File file_m2 = new File(
                fileId
                );

            //act
            file_m2.fileId = 2;

            //assert
            Assert.IsNotNull(file_m2, "file object is null");
            Assert.AreEqual(2, file_m2.fileId, "fileId not changed");
        }
        //LAYER_Class_NameOfTheMethod_TestedScenario_ExpectedBehaviour
        public void BLL_CtrFile_InsertFile_InsertFile_FileIsInserted()
        {
            //arrange
            int fileId = 1;

            File file_m1 = new File(
                fileId
                );
            CtrFile _CtrFile = new CtrFile();

            //act
            int result = _CtrFile.insertFile(file_m1);

            //assert
            
            Assert.IsTrue(result >= (int)ENUM.CODE.TRANSLATO_DATABASE_SEED, "file not inserted");
        }
Example #6
0
        //returns [int >= TRANSLATO_DATABASE_SEED] if successful
        //returns [int < TRANSLATO_DATABASE_SEED] if not
        internal int insertFile(File file)
        {
            int returnCode = (int)CODE.ZERO;
            int result = (int)CODE.MINUS_ONE;

            //validate -> ToDo
            if (
                result == (int)CODE.ZERO ||
                returnCode != (int)CODE.ZERO
               ) { returnCode = (int)CODE.CTRTEXT_INSERTTEXT_INVALID_TEXTDATA; result = (int)CODE.ZERO; }
            if (returnCode == (int)CODE.ZERO && result != (int)CODE.ZERO)//safe to proceed
            {
                IFiles _DbFiles = new DbFiles();

                try
                {
                    using (var trScope = TransactionScopeBuilder.CreateSerializable())
                    {
                        returnCode = _DbFiles.insertFile(file);

                        trScope.Complete();
                    }
                }
                catch (TransactionAbortedException taEx)
                {
                    returnCode = (int)CODE.CTRFILE_INSERTFILE_EXCEPTION;
                    Log.Add(taEx.ToString());
                }
                catch (ApplicationException aEx)
                {
                    returnCode = (int)CODE.CTRFILE_INSERTFILE_EXCEPTION;
                    Log.Add(aEx.ToString());
                }
                catch (Exception ex)
                {
                    returnCode = (int)CODE.CTRFILE_INSERTFILE_EXCEPTION;
                    Log.Add(ex.ToString());
                }
            }
            else { }
            return returnCode;
        }