sql server - Test Function in MVC Project -


So I want to test my work in my web project, but it is actually nothing connected to the project (Someone else is working on that part). Moves the function to the "id" field, goes to some queries and receives some data, computes some, and then writes a file stream a bunch of lines and returns the stream. I just want to test it by writing a file locally on my computer and after the completion of the function I want to work with that file directory.

So my question is mainly:

1) How do I call test purposes only for this purpose, so that I have not yet asked all questions without connecting to any other part of the application / Computation / write file, etc.

2) How to

Thanks guys!

To make your function testable, you need to separate all your dependencies and Replace your test with Stubbs Mock. You can get it through the wrappers around the file system classes and make sure that your data layer classes have interfaces, and your code can look like this:

  {IDataProvider Provider; IFile system file system; Some public (IDataProvider Provider, IFileSystem File System) {this.provider = Provider; This.fileSystem = fileSystem; } Data Doctoring (int id) {// create data data to get data data = provider.GetData (ID); FileSystem.Write ("someFilePath", data); }}  

With this you can write a test (using syntax as in this sentence):

  zero something () MockDataProvider = new Fake & lt; idataProvider & gt; (); Var Mockfile System = New Fake & lt; IFileSystem & gt; (); Var Some = New Something (MockDataProvider.Object, Mockfile System.Object); Var Data = "Some Data "; CcDetPrint. Setup (x = & gt; x.GetData (5)) Return (data); DoThing (5); MockFileSystem.Verify (x = & gt; x.Write (" someFilePath ", data); }  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -