Angular Testing Series: How to add Jest to Angular project smoothly

When we have a chance to participate in an Angular project from the very beginning, we probably have an impact on many architectural aspects. One of these aspects is the selection of an appropriate techniques and testing tools. In plethora of projects, the standard tool that comes with Angular is used: Karma and Jasmine.

However, it is important to realize that the choice of Test Runner is not limited to Karma. For some reasons, it is worth taking an interest in Jest.

What possible benefits does bring Jest to your project? 📘

  • Faster experience and parallelized test runs out of box
  • Various functionalities provided with Jest CLI that support work efficiency
  • Simple faking, spying and mocking
  • Built-in assertions and code coverage
  • Typescript support

… and honestly, many more functionalities that you can read about in the documentation. Now, let’s focus on the practical aspect and purpose, which is adding JEST to your Angular project.

#programming #angular #testing #software-development #jest

What is GEEK

Buddha Community

Angular Testing Series: How to add Jest to Angular project smoothly

Angular Testing Series: How to add Jest to Angular project smoothly

When we have a chance to participate in an Angular project from the very beginning, we probably have an impact on many architectural aspects. One of these aspects is the selection of an appropriate techniques and testing tools. In plethora of projects, the standard tool that comes with Angular is used: Karma and Jasmine.

However, it is important to realize that the choice of Test Runner is not limited to Karma. For some reasons, it is worth taking an interest in Jest.

What possible benefits does bring Jest to your project? 📘

  • Faster experience and parallelized test runs out of box
  • Various functionalities provided with Jest CLI that support work efficiency
  • Simple faking, spying and mocking
  • Built-in assertions and code coverage
  • Typescript support

… and honestly, many more functionalities that you can read about in the documentation. Now, let’s focus on the practical aspect and purpose, which is adding JEST to your Angular project.

#programming #angular #testing #software-development #jest

Autumn  Blick

Autumn Blick

1593867420

Top Android Projects with Source Code

Android Projects with Source Code – Your entry pass into the world of Android

Hello Everyone, welcome to this article, which is going to be really important to all those who’re in dilemma for their projects and the project submissions. This article is also going to help you if you’re an enthusiast looking forward to explore and enhance your Android skills. The reason is that we’re here to provide you the best ideas of Android Project with source code that you can choose as per your choice.

These project ideas are simple suggestions to help you deal with the difficulty of choosing the correct projects. In this article, we’ll see the project ideas from beginners level and later we’ll move on to intermediate to advance.

top android projects with source code

Android Projects with Source Code

Before working on real-time projects, it is recommended to create a sample hello world project in android studio and get a flavor of project creation as well as execution: Create your first android project

Android Projects for beginners

1. Calculator

build a simple calculator app in android studio source code

Android Project: A calculator will be an easy application if you have just learned Android and coding for Java. This Application will simply take the input values and the operation to be performed from the users. After taking the input it’ll return the results to them on the screen. This is a really easy application and doesn’t need use of any particular package.

To make a calculator you’d need Android IDE, Kotlin/Java for coding, and for layout of your application, you’d need XML or JSON. For this, coding would be the same as that in any language, but in the form of an application. Not to forget creating a calculator initially will increase your logical thinking.

Once the user installs the calculator, they’re ready to use it even without the internet. They’ll enter the values, and the application will show them the value after performing the given operations on the entered operands.

Source Code: Simple Calculator Project

2. A Reminder App

Android Project: This is a good project for beginners. A Reminder App can help you set reminders for different events that you have throughout the day. It’ll help you stay updated with all your tasks for the day. It can be useful for all those who are not so good at organizing their plans and forget easily. This would be a simple application just whose task would be just to remind you of something at a particular time.

To make a Reminder App you need to code in Kotlin/Java and design the layout using XML or JSON. For the functionality of the app, you’d need to make use of AlarmManager Class and Notifications in Android.

In this, the user would be able to set reminders and time in the application. Users can schedule reminders that would remind them to drink water again and again throughout the day. Or to remind them of their medications.

3. Quiz Application

Android Project: Another beginner’s level project Idea can be a Quiz Application in android. Here you can provide the users with Quiz on various general knowledge topics. These practices will ensure that you’re able to set the layouts properly and slowly increase your pace of learning the Android application development. In this you’ll learn to use various Layout components at the same time understanding them better.

To make a quiz application you’ll need to code in Java and set layouts using xml or java whichever you prefer. You can also use JSON for the layouts whichever preferable.

In the app, questions would be asked and answers would be shown as multiple choices. The user selects the answer and gets shown on the screen if the answers are correct. In the end the final marks would be shown to the users.

4. Simple Tic-Tac-Toe

android project tic tac toe game app

Android Project: Tic-Tac-Toe is a nice game, I guess most of you all are well aware of it. This will be a game for two players. In this android game, users would be putting X and O in the given 9 parts of a box one by one. The first player to arrange X or O in an adjacent line of three wins.

To build this game, you’d need Java and XML for Android Studio. And simply apply the logic on that. This game will have a set of three matches. So, it’ll also have a scoreboard. This scoreboard will show the final result at the end of one complete set.

Upon entering the game they’ll enter their names. And that’s when the game begins. They’ll touch one of the empty boxes present there and get their turn one by one. At the end of the game, there would be a winner declared.

Source Code: Tic Tac Toe Game Project

5. Stopwatch

Android Project: A stopwatch is another simple android project idea that will work the same as a normal handheld timepiece that measures the time elapsed between its activation and deactivation. This application will have three buttons that are: start, stop, and hold.

This application would need to use Java and XML. For this application, we need to set the timer properly as it is initially set to milliseconds, and that should be converted to minutes and then hours properly. The users can use this application and all they’d need to do is, start the stopwatch and then stop it when they are done. They can also pause the timer and continue it again when they like.

6. To Do App

Android Project: This is another very simple project idea for you as a beginner. This application as the name suggests will be a To-Do list holding app. It’ll store the users schedules and their upcoming meetings or events. In this application, users will be enabled to write their important notes as well. To make it safe, provide a login page before the user can access it.

So, this app will have a login page, sign-up page, logout system, and the area to write their tasks, events, or important notes. You can build it in android studio using Java and XML at ease. Using XML you can build the user interface as user-friendly as you can. And to store the users’ data, you can use SQLite enabling the users to even delete the data permanently.

Now for users, they will sign up and get access to the write section. Here the users can note down the things and store them permanently. Users can also alter the data or delete them. Finally, they can logout and also, login again and again whenever they like.

7. Roman to decimal converter

Android Project: This app is aimed at the conversion of Roman numbers to their significant decimal number. It’ll help to check the meaning of the roman numbers. Moreover, it will be easy to develop and will help you get your hands on coding and Android.

You need to use Android Studio, Java for coding and XML for interface. The application will take input from the users and convert them to decimal. Once it converts the Roman no. into decimal, it will show the results on the screen.

The users are supposed to just enter the Roman Number and they’ll get the decimal values on the screen. This can be a good android project for final year students.

8. Virtual Dice Roller

Android Project: Well, coming to this part that is Virtual Dice or a random no. generator. It is another simple but interesting app for computer science students. The only task that it would need to do would be to generate a number randomly. This can help people who’re often confused between two or more things.

Using a simple random number generator you can actually create something as good as this. All you’d need to do is get you hands-on OnClick listeners. And a good layout would be cherry on the cake.

The user’s task would be to set the range of the numbers and then click on the roll button. And the app will show them a randomly generated number. Isn’t it interesting ? Try soon!

9. A Scientific Calculator App

Android Project: This application is very important for you as a beginner as it will let you use your logical thinking and improve your programming skills. This is a scientific calculator that will help the users to do various calculations at ease.

To make this application you’d need to use Android Studio. Here you’d need to use arithmetic logics for the calculations. The user would need to give input to the application that will be in terms of numbers. After that, the user will give the operator as an input. Then the Application will calculate and generate the result on the user screen.

10. SMS App

Android Project: An SMS app is another easy but effective idea. It will let you send the SMS to various no. just in the same way as you use the default messaging application in your phone. This project will help you with better understanding of SMSManager in Android.

For this application, you would need to implement Java class SMSManager in Android. For the Layout you can use XML or JSON. Implementing SMSManager into the app is an easy task, so you would love this.

The user would be provided with the facility to text to whichever number they wish also, they’d be able to choose the numbers from the contact list. Another thing would be the Textbox, where they’ll enter their message. Once the message is entered they can happily click on the send button.

#android tutorials #android application final year project #android mini projects #android project for beginners #android project ideas #android project ideas for beginners #android projects #android projects for students #android projects with source code #android topics list #intermediate android projects #real-time android projects

How to Build an NFT Project with Foundry & Figment DataHub

GitHub Repo:- https://github.com/PradhumnaPancholi/Figbot

Hey everyone! A little while ago, I was learning Dapp Tools as it has fantastic tools for developing and auditing smart contracts. And although I loved the experience, I soon learned that it is in the clandestine development stage. This means that casual/individual users can not depend on maintainers for support and updates.

Then I stumbled upon Foundry. It has everything that Dapp Tools offers apart from built-in symbolic execution (which is not a problem for me as I use Manticore by Trail of Bits ). And this is auditing related hence not a hindrance in smart contract development by any stretch of the imagination.

After working with Foundry for a bit, I enjoyed the experience and wanted to share that with others. Hence, this article.

This article will go through the benefits of Foundry, the installation process, developing an NFT (because everyone is interested in that), testing the contract, and deploying it with Figment Datahub.

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.

Foundry is made up of three components:

  • Forge: Ethereum testing framework (like Truffle, Hardhat, and Dapptools).
  • Cast: Swiss army knife for interacting with EVM smart contracts, sending transactions, and getting chain data.
  • Anvil: local Ethereum node, akin to Ganache, Hardhat Network

Today’s focus is going to be on Forge. But I will be posting in-depth articles on Caste and Anvil in the upcoming weeks.

#Why Foundry:

There are many smart contract development tools like Truffle, Hardhat, and Brownie. But one of my primary reasons for looking into Dapp Tools in the first place was native Solidity tests. Writing smart contracts is not hard when switching between frameworks like Hardhat and Brownie. And they are incredible tools with plugins, but one needs to be well versed in JavaScript/TypeScript and Python to perform testing.

Foundry allows us to write our tests natively in Solidity. This saves a lot of time onboarding new developers and makes the process smoother. In my experience of helping people navigate their way into smart contracts development, I have learned that the best and most efficient way for junior developers to engage with DAO/community-maintained projects is by writing tests and learning about the code-base itself. I remember Scupy Trooples once mentioned that they used the same approach while developing Alchemix Finance on Bankless.

In addition to that, built-in fuzzing, cheat codes, Cast, and Anvil make it a solid suite for testing smart contracts. There will be more detailed articles on those components coming soon. [Easy to integrate static analyzer]

Let’s dive in and build an NFT project now.

#Installation:

If you are on Mac or Linux, all you need to do is run two commands:

curl -L https://foundry.paradigm.xyz | bash

foundryup

Make sure to close the terminal before running foundryup .

And Voila! You are all done.

For Windows, you need to have Rust installed and then :

cargo install --git https://github.com/foundry-rs/foundry --locked

#Project Setup:

For this article, we will be creating a simple NFT project called Figbots.

Start by creating a directory called “Figbots.” And run forge initonce you are inside the directory. This command will create a foundry project for you with git initialized.

Let’s take a quick look at the folder structure. You have three primary folders, namely src, lib, and test. Very much self-explanatory here, you write your contracts in src, tests in test, and lib contains all the libraries you installed, e.g., OpenZeppelin. In addition to that, you get foundry.toml which contains all the configurations just like hardhat.config.js and brownie-config.yaml if you have used those frameworks. Another sweet thing is .github, where you can write your Github Actions. I find it really helpful for tests when working in a team.

Let’s start building! We will create a simple NFT called Figbot with a limited supply, cost (for minting), and withdrawal. With this approach, we can cover edges for different tests. First of all, rename Contract.sol and test/Contract.t.sol to Figbot.sol and Figbot.t.sol respectively. Now, we can not write smart contracts without Openzeppelin, can we?

Installing libraries with Foundry is slightly different than Hardhat and Brownie. We don’t have npm or pip packages. We install libraries directly from the Source (GitHub repo) in Foundry.

forge install Openzeppelin/openzeppelin-contracts

Now we can import the ERC721URIStorage.sol extension to create our NFT. To check that everything is alright, we can run the command forge build , and it will compile our project. The compiler will yell at you if there is something wrong. Otherwise, you will get a successful compile.

#Managing dependencies

Just like any other package manager, Forge allows you to use forge install <lib>, forge remove <lib>, and forge update <lib> to manage your dependencies.

#Let’s Complete The NFT Contract:

We will be using three contracts from the Openzeppelin. Counters, ERC721URIStorage, and Ownable. Time to upload our asset to IPFS using Pinata. We use the Ownable contract to set deploying address owner and have access to onlyOwner modifier to allow only the owner to withdraw funds. Counters to help us with token id(s) and ERC721URIStorage to keep the NFT contract simple.

  1. Setting state variable:
  1. MAX_SUPPLY to 100
  2. COST to 0.69 ether
  3. TOKEN_URI to CID, we receive from Pinata

2. Using Counter for token id:

  1. using Counters for Counters.Counter;
  2. Counters.Counter private tokenIds;

3. ERC721 constructor:

constructor() ERC721(“Figbot”, “FBT”) {}

4. Mint function:

  1. Check if msg.value is greater than COST
  2. Check if tokenIds.current() is greater or equal to MAX_SUPPLY
  3. Perform _safeMint and _setTokenURI

5. Withdraw function:

function withdrawFunds() external onlyOwner { uint256 balance = address(this).balance; require(balance > 0, "No ether left to withdraw"); (bool success, ) = (msg.sender).call{value: balance}(""); require(success, "Withdrawal Failed"); emit Withdraw(msg.sender, balance); }

6. TotalSupply function:

function totalSupply() public view returns (uint256) { return _tokenIds.current(); }

#Testing The Contract:

As we all know, testing our smart contracts is really important. In this section, we will be writing some tests to get a solid understanding of forge test and get used to writing tests in native solidity. We will be three Foundry cheat codes (I love them!) to manage account states to fit our test scenario.

We will be testing for the following scenarios:

  • Max Supply
  • Successful mint
  • Failed mint due to insufficient balance
  • Withdraw (by owner)

#Cheatcodes

As we can have complex logic in our smart contracts. And they are expected to behave differently depending on the state, the account used to invoke, time, etc. To deal with such scenarios, we can use cheatcodes to manage the state of the blockchain. We can use these cheatcodes using vm instance, which is a part of Foundry’s Test library.

We will be using three cheatcodes in our tests :

startPrank : Sets msg.sender for all subsequent calls until stopPrank is called.

stopPrank:

Stops an active prank started by startPrank, resetting msg.sender and tx.origin to the values before startPrank was called.

deal : Sets the balance of an address provided address to the given balance.

#Setup

Foundry comes with a built-in testing library. We start by importing this test library, our contract (the one we want to test), defining the test, setting variables, and setUp function.

pragma solidity ^0.8.13;

import"forge-std/Test.sol";
import "../src/Figbot.sol";

contract FigbotTest is Test {

  Figbot figbot;
  address owner = address(0x1223);
  address alice = address(0x1889);
  address bob = address(0x1778);
  
  function setUp() public {
      vm.startPrank(owner);
      figbot = new Figbot();
      vm.stopPrank(); 
  }
}

For state variables, we create a variable figbot of type Figbot . This is also the place where I like to define user accounts. In Foundry, you can describe an address by using the syntax address(0x1243). you can use any four alphanumeric characters for this. I have created the accounts named owner, Alice, and bob, respectively.

Now our setUp function. This is a requirement for writing tests in Foundry. This is where we do all the deployments and things of that nature. I used the cheatcode startPrank to switch the user to the “owner.” By default, Foundry uses a specific address to deploy test contracts. But that makes it harder to test functions with special privileges like withdrawFunds . Hence, we switch to the “owner” account for this deployment.

#Test MaxSupply:

Starting with a simple assertion test to learn Foundry convention. By convention, all the test functions must have the prefix test . And we use assertEq to test if two values are equal.

We call our MaxSupply function and test if the result value is 100, as we described in our contract. And we use forge test to run our tests.

And Voila!!! we have a passed test.

#Test Mint:

Now that we have written a simple test, let’s write one with cheatcodes. The primary function of our contract.

  • Switch user account to Alice.
  • Set Alice’s balance to 1 ether
  • Call the mint function
  • Check if balanceOf Alice is 1

#TestFail Mint:

We have another testing function used for tests that we expect to fail. The prefix used for such a test is testFail . We will test if the mint function reverts if the caller has insufficient funds.

Switch user account to Bob

Set Bob’s balance to 0.5 ether (our NFT is 0.69 ether)

Call the mint function (it will be reverted due to not having enough funds)

Check if balanceOf Bob is 1

Because mint didn’t go through, the balance of Bob is not going to be 1. Hence, it will fail, which is exactly what we are used testFail for. So when you run forge test, it will pass.

#Test Withdraw:

Here we will test a function that only the “owner” can successfully perform. For this test, we will :

  • Switch user to Bob
  • Give Bob’s account the balance of 1 ether
  • Mint a Figbot from Bob’s account ( this will give the contract a balance of 0.69 ether )
  • Switch the user to the owner account
  • Perform withdrawFunds function ( if successful, it should make the owner’s balance 0.69 ether)

To verify, we assert if the owner’s balance is 0.69 ether

Deployment:

Now that we have tested our contract, it is time to deploy it. We need private keys to a wallet (with some Rinkeby test ETH) and an RPC URL. For our RPC URL, we will use Figment DataHu.

Figment DataHub provides us with infrastructure to develop on Web 3. It supports multiple chains like Ethereum, Celo, Solana, Terra, etc.

#Setting up Figment DataHub:

  • Create an account on Figment DataHub.
  • Click on “Create New App.”
  • Fill in the app name.
  • Choose “Staging” for the environment.
  • Select “Ethereum” from the provided options.

You can get your RPC URL for Rinkeby from under the “Protocols” tab.

Open your terminal to enter both of these things as environment variables.

export FIG_RINKEBY_URL=<Your RPC endpoint>
export PVT_KEY=<Your wallets private key>

Once we have the environment variables, we are all set to deploy

forge create Figbot --rpc-url=$FIG_RINKEBY_URL --private-key=$PVT_KEY

#Verification:

We are almost done here. So far, we have written, tested, and deployed a smart contract with Foundry and Figment DataHub. But we are not entirely done just yet. We are now going to verify our contract. We will need to set up our Etherscan API key for that.

export ETHERSCAN_API=<Your Etherscan API Key>

And now we can verify our smart contract.

forge verify-contract --chain-id <Chain-Id> --num-of-optimizations 200 --compiler-version <Compiler Version> src/<Contract File>:<Contract> $ETHERSCAN_API

Congratulations! Now you can write, test, and deploy smart contracts using Foundry. I hope you enjoyed and learned from this article. I indeed enjoyed writing this. Feel free to let me know your thoughts about it. 

This story was originally published at https://hackernoon.com/how-to-build-an-nft-project-with-foundry-and-figment-datahub

#nft #datahub

Shawn  Durgan

Shawn Durgan

1595547778

10 Writing steps to create a good project brief - Mobile app development

Developing a mobile application can often be more challenging than it seems at first glance. Whether you’re a developer, UI designer, project lead or CEO of a mobile-based startup, writing good project briefs prior to development is pivotal. According to Tech Jury, 87% of smartphone users spend time exclusively on mobile apps, with 18-24-year-olds spending 66% of total digital time on mobile apps. Of that, 89% of the time is spent on just 18 apps depending on individual users’ preferences, making proper app planning crucial for success.

Today’s audiences know what they want and don’t want in their mobile apps, encouraging teams to carefully write their project plans before they approach development. But how do you properly write a mobile app development brief without sacrificing your vision and staying within the initial budget? Why should you do so in the first place? Let’s discuss that and more in greater detail.

Why a Good Mobile App Project Brief Matters?

Why-a-Good-Mobile-App-Project-Brief-Matters

It’s worth discussing the significance of mobile app project briefs before we tackle the writing process itself. In practice, a project brief is used as a reference tool for developers to remain focused on the client’s deliverables. Approaching the development process without written and approved documentation can lead to drastic, last-minute changes, misunderstanding, as well as a loss of resources and brand reputation.

For example, developing a mobile app that filters restaurants based on food type, such as Happy Cow, means that developers should stay focused on it. Knowing that such and such features, UI elements, and API are necessary will help team members collaborate better in order to meet certain expectations. Whether you develop an app under your brand’s banner or outsource coding and design services to would-be clients, briefs can provide you with several benefits:

  • Clarity on what your mobile app project “is” and “isn’t” early in development
  • Point of reference for developers, project leads, and clients throughout the cycle
  • Smart allocation of available time and resources based on objective development criteria
  • Streamlined project data storage for further app updates and iterations

Writing Steps to Create a Good Mobile App Project Brief

Writing-Steps-to-Create-a-Good-Mobile-App-Project-Brief

1. Establish the “You” Behind the App

Depending on how “open” your project is to the public, you will want to write a detailed section about who the developers are. Elements such as company name, address, project lead, project title, as well as contact information, should be included in this introductory segment. Regardless of whether you build an in-house app or outsource developers to a client, this section is used for easy document storage and access.

#android app #ios app #minimum viable product (mvp) #mobile app development #web development #how do you write a project design #how to write a brief #how to write a project summary #how to write project summary #program brief example #project brief #project brief example #project brief template #project proposal brief #simple project brief template

Christa  Stehr

Christa Stehr

1598940617

Install Angular - Angular Environment Setup Process

Angular is a TypeScript based framework that works in synchronization with HTML, CSS, and JavaScript. To work with angular, domain knowledge of these 3 is required.

  1. Installing Node.js and npm
  2. Installing Angular CLI
  3. Creating workspace
  4. Deploying your First App

In this article, you will get to know about the Angular Environment setup process. After reading this article, you will be able to install, setup, create, and launch your own application in Angular. So let’s start!!!

Angular environment setup

Install Angular in Easy Steps

For Installing Angular on your Machine, there are 2 prerequisites:

  • Node.js
  • npm Package Manager
Node.js

First you need to have Node.js installed as Angular require current, active LTS or maintenance LTS version of Node.js

Download and Install Node.js version suitable for your machine’s operating system.

Npm Package Manager

Angular, Angular CLI and Angular applications are dependent on npm packages. By installing Node.js, you have automatically installed the npm Package manager which will be the base for installing angular in your system. To check the presence of npm client and Angular version check of npm client, run this command:

  1. npm -v

Installing Angular CLI

  • Open Terminal/Command Prompt
  • To install Angular CLI, run the below command:
  1. npm install -g @angular/cli

installing angular CLI

· After executing the command, Angular CLI will get installed within some time. You can check it using the following command

  1. ng --version

Workspace Creation

Now as your Angular CLI is installed, you need to create a workspace to work upon your application. Methods for it are:

  • Using CLI
  • Using Visual Studio Code
1. Using CLI

To create a workspace:

  • Navigate to the desired directory where you want to create your workspace using cd command in the Terminal/Command prompt
  • Then in the directory write this command on your terminal and provide the name of the app which you want to create. In my case I have mentioned DataFlair:
  1. Ng new YourAppName

create angular workspace

  • After running this command, it will prompt you to select from various options about the CSS and other functionalities.

angular CSS options

  • To leave everything to default, simply press the Enter or the Return key.

angular setup

#angular tutorials #angular cli install #angular environment setup #angular version check #download angular #install angular #install angular cli