Tutorial by Examples

Use >-> to connect Producers, Consumers and Pipes to compose larger Pipe functions. printNaturals :: MonadIO m => Effect m () printNaturals = naturalsUntil 10 >-> intToStr >-> fancyPrint Producer, Consumer, Pipe, and Effect types are all defined in terms of the general Prox...
pipes's core data type is the Proxy monad transformer. Pipe, Producer, Consumer and so on are defined in terms of Proxy. Since Proxy is a monad transformer, definitions of Pipes take the form of monadic scripts which await and yield values, additionally performing effects from the base monad m.
data: lv_temp type string. data: ls_temp type sy. data: lt_temp type table of sy.
data: gv_temp type string. data: gs_temp type sy. data: gt_temp type table of sy.
Unsafe is stored as a private field that cannot be accessed directly. The constructor is private and the only method to access public static Unsafe getUnsafe() has privileged access. By use of reflection, there is a work-around to make private fields accessible: public static final Unsafe UNSAFE; ...
Some uses of unsafe is s follows: UseAPIOff heap / direct memory allocation, reallocation and deallocationallocateMemory(bytes), reallocateMemory(address, bytes) and freeMemory(address)Memory fencesloadFence(), storeFence(), fullFence()Parking current threadpark(isAbsolute, time), unpark(thread)Dir...
$perl -d:MOD script.pl runs the program under the control of a debugging, profiling, or tracing module installed as Devel::MOD. For example, -d:NYTProf executes the program using the Devel::NYTProf profiler. See all available Devel modules here Recommended modules: Devel::NYTProf -- Powerful ...
Mocks are meant as test doubles, that allow interactions with the mocks to be validated, they are not meant to replace the system you are testing. Examples will often demonstrate features of Moq as follows: // Create the mock var mock = new Mock<IMockTarget>(); // Configure the mock to d...
An ActionResult can return FileContentResult by specifying file path and file type based from extension definition, known as MIME type. The MIME type can be set automatically depending on file type using GetMimeMapping method, or defined manually in proper format, e.g. "text/plain". Sinc...
User controls are made for reusability across ASP.NET pages, similar to master pages. Instead of sharing base page layout, user controls share group of HTML/ASP.NET built-in server controls or a specific form layout, e.g. comment submission or guest notes. A user control can contain both HTML contr...
If you want to instantiate an instance of user control inside ASPX code behind page, you need to write user control declaration on Page_Load event as follows: public partial class Default : System.Web.UI.Page { protected void Page_Load(Object sender, EventArgs e) { Control contr...
Like standard ASP.NET built-in server controls, user controls can have properties (attributes) on its definition tag. Suppose you want to add color effect on UserControl.ascx file like this: <uc:UserControl ID="UserControl1" runat="server" Color="blue" /> At t...
Sometimes you want to mock a class or an interface and have its properties behave as if they were simple getters and setters. As this is a common requirement, Moq provides a short cut method to setup all properties of a mock to store and retrieve values: // SetupAllProperties tells mock to impleme...
Sometimes you want to create a mock of a class that has a private setter: public class MockTarget { public virtual string PropertyToMock { get; private set; } } Or an interface that only defines a getter: public interface MockTarget { string PropertyToMock { get; } } In both ca...
Where a method to be tested uses information from one call to pass on to subsequent calls, one approach that can be used to ensure the methods are called in the expected order is to setup the expectations to reflect this flow of data. Given the method to test: public void MethodToTest() { va...
When you can't / don't want to use Strict Mocks, you can't use MockSequence to validate call order. An alternate approach is to use callbacks to validate that the Setup expectations are being invoked in the expected order. Given the following method to test: public void MethodToTest() { _ut...
Moq provides support for validating call order using MockSequence, however it only works when using Strict mocks. So, Given the following method to test: public void MethodToTest() { _utility.Operation1("1111"); _utility.Operation2("2222"); _utility.Operation3(&...
Mocking an interface that inherits from IEnumerable to return canned data is quite straightforward. Assuming the following classes: public class DataClass { public int Id { get; set; } } public interface IEnumerableClass : IEnumerable<DataClass> { } The following approach can ...
Assume that we are using Page object model. Page Object class: import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; public cla...
As an example of writing input & output, we'll take in a real value and return the value and its square until the user enters a negative number. As specified below, the read command takes two arguments: the unit number and the format specifier. In the example below, we use * for the unit number...

Page 921 of 1336