Tutorial by Examples: er

module main; auto getMemberNames(T)() @safe pure { string[] members; foreach (derived; __traits(derivedMembers, T)) { members ~= derived; } return members; } class Foo { int a; int b; } class Bar : Foo { int c; int d; int e...
A Producer is some monadic action that can yield values for downstream consumption: type Producer b = Proxy X () () b yield :: Monad m => a -> Producer a m () For example: naturals :: Monad m => Producer Int m () naturals = each [1..] -- each is a utility function exported by Pipes ...
A Consumer can only await values from upstream. type Consumer a = Proxy () a () X await :: Monad m => Consumer a m a For example: fancyPrint :: MonadIO m => Consumer String m () fancyPrint = forever $ do numStr <- await liftIO $ putStrLn ("I received: " ++ numStr) ...
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.
$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 ...
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 ...
Given you've already installed composer up and running and it's accessible globally, you can simply create new Symfony projects as stated in the official documentation. Now you can create a new Symfony project with composer: composer create-project symfony/framework-standard-edition my_project_nam...
NumericUpDown is control that looks like TextBox. This control allow user to display/select number from a range. Up and Down arrows are updating the textbox value. Control look like; In Form_Load range can be set. private void Form3_Load(object sender, EventArgs e) { numericUpDown...
Socket creation Create a socket that uses the TCP. It is the same as creating a client socket. $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); Socket binding Bind connections from a given network (parameter 2) for a specific port (parameter 3) to the socket. The second parameter is us...
socket_last_error can be used to get the error ID of the last error from the sockets extension. socket_strerror can be used to convert the ID to human-readable strings. function onSocketFailure(string $message, $socket = null) { if(is_resource($socket)) { $message .= ": " ....
A UDP (user datagram protocol) server, unlike TCP, is not stream-based. It is packet-based, i.e. a client sends data in units called "packets" to the server, and the client identifies clients by their address. There is no builtin function that relates different packets sent from the same c...
Sub Theloopofloops() Dim wbk As Workbook Dim Filename As String Dim path As String Dim rCell As Range Dim rRng As Range Dim wsO As Worksheet Dim sheet As Worksheet path = "pathtofile(s)" & "\" Filename = Dir(path & "*.xl??") Set wsO =...

Page 290 of 417